The Virtual World (Model Transformations)
Note
These are my rough notes based on attending CS148. They might contain errors so proceed with caution!
Our goal is to mimic human vision in a virtual world. We do this by:
- Creating a virtual camera and placing it somewhere to point at something.
- Putting a film that contains pixels with RGB values between 0 and 255 into the camera.
- Placing some objects in the world. (geometric modeling, transformations, texture mapping).
- Putting lights in the scene.
- And Finally taking the picture. The light will bounce around the room hitting the objects and back hitting the camera onto the virtual film.
Rotations
In 2D, we can rotate a point counter clock-wise about the origin with
and in 3D, we’ll have three possible rotations depending on which axis we’re rotating around. If we’re rotating against the x-axis then we’ll have:
All standard stuff but the cool part was the next topic which is proving that these rotations preserve line segments and angels!
Rotations Preserve Line Segments
Consider two points \(p\) and \(q\) and the line segment between them. Write the line segment in terms of these points
so if \(\alpha\) is 0, then we get \(p\) and if \(\alpha\) is 1 then we get the point \(q\). Apply the rotation \(R\) on each point by multiplying the points on the light segment
When \(\alpha = 0\), we get \(Ru(0) = Rp\) and when \(\alpha = 1\), we get \(Ru(1)=Rq\). We know \(0 \leq \alpha \leq 1\) specifies all the points connecting \(Rp\) and \(Rq\). This means that we only need to rotate the endpoints in order to construct the new line segment connecting them. Next, we will show that the distance between the two rotated points is equivalent to the distance between the original points,
so the distance is preserved.
Rotations Preserve Angels
Consider two line segments \(u\) and \(v\). The claim is that the angel between two is preserved after \(u\) and \(v\) are rotated.
Proof:
We also know
So the angel between \(u\) and \(v\) is the same as the angle between \(Ru\) and \(Rv\).
Rotations Preserve Shape
TODO
Scaling (Resizing)
The shear/scaling matrix (keeping in mind that shearing cause distortions)
if \(s_1 = s_2 = s_3 = s\), then the object is just getting scaled. In that case, distances between line segments increase/decrease by a factor of \(s\) and the angles between line segments are preserved. (Similar Proof to the Rotation Proof)
Homogenous Coordinates
Before we can talk about translation, we need to introduce homogenous coordinates. The reason is because we want to do translations with matrix multiplication to speed things up. Instead of applying each transformation separately, now we can multiply all these transformations first and then apply them all at once.
- The homogeneous coordinates of a 3D point \(x\) = (x, y, z) are
for any \(w \neq 0\).
- We typically convert points to homogenous coordinates by setting \(w = 1\) for points and \(w = 0\) for vectors to deal with translations while vectors have \(w = 0\).
Order Matters!
Suppose we want to rotate by 45 degrees around the x-axis and then translate all the points by \((t_1, t_2, t_3)\). We can use homogenous coordinates to accomplish this but we need to remember that we need to rotate first and then translate. If we change the order, then we’ll get a completely different transformations. To correctly apply the transformations, \(M_1\) followed by \(M_2\), we’ll need to multiply the matrices in the reverse order \(M_2M_1\), meaning that we’re applying \(M_1\) first.
And now we can multiply all of them first before finally multiplying them with a vector or a point from our scene
\(w\) above is either 0 or 1 depending if this is a vector or a point. Note here that if you multiply the translation matrix by a vector then it has no effect as expected. The 0 will cancel out the effect. This doesn’t happen with points. So for points,
while for vectors,
References
Fundamentals of Computer Graphics, 4th Edition
CS148 Lectures