COMP3421 – Lec 2 – Transformations
Interestingly we can use the extra dimension in homogeneous coordinates to distinguish a point from a vector. A point will have a 1 in the last component, and a vector will have a 0. The difference between a point and a vector is a bit wish washy in my mind so I’m not sure why this distinction helps.
Transforming a Point
Say we have the 2D point . This point as a column vector in homogeneous coordinates is . For a multiplication between this vector and a transformation matrix (3 by 3) to work we need to do the matrix times the vector (in that order) to give the translated vector, .
Say we want to do a translation then a rotation (A then B) on the point x. First we must do , then . That is . The order is important as matrix multiplication in not commutative, ie. (just think a translation then a rotation is not necessarily the same as a rotate then a move (by the same amounts)). If we do lots of transformations we may get something like , this is in effect doing transformation A then B then C then D. (Remember matrix multiplication is associative, i.e. ).
As a side note, if you express your point as a row vector (eg. ), then to do a transformation you must do (where x is the point/row vector). In this case is equivalent to doing transformation A on point x, then transformation B then C (apparently this is how DirectX works).
Affine transformations are a special kind of transformation. They have a matrix form where the last row is [0 … 0 1]. An affine transformation is equivalent to a linear transformation followed by a translation. That is, is the same as .
Something interesting to note is, the inverse transformation of an affine transformation is another affine transformation, whose matrix is the inverse matrix of the original. Also an affine transformation in 2D is uniquely defined by its action on three points.
From page 209 of the text (Hill, 2006), affine transformations have some very useful properties.
1. Affine Transformations Preserve Affine Combinations of Points
For some affine transformation T, points P1 and P2, and real’s a1 and b1 where a1 + b1 = 1,
2. Affine Transformations Preserve Lines and Planes
That is under any affine transformation lines transformed are still lines (they don’t suddenly become curved), similarly planes that are transformed are still planes.
3. Parallelism of Lines and Planes is Preserved
“If two lines or planes are parallel, their images under an affine transformation are also parallel.” The explanation that Hill uses is rather good,
Take an arbitrary line A + bt having direction b. It transforms to the line given in homogeneous coordinates by M(A + bt) = MA + (Mb)t, this transformed line has direction vector Mb. This new direction does not depend on point A. Thus two different lines and that have the same direction will transform into two lines both having the direction , so they are parallel. The same argument can be applied to planes and beyond.
4. The Columns of the Matrix Reveal the Transformed Coordinate Frame
Take a generic affine transformation matrix for 2D,
The first two columns, and , are vectors (last component is 0). The last column is a point (last component is a 1).
Using the standard basis vectors , with origin , notice that i transforms to the vector . . Similarily for and .
5. Relative Ratios are Preserved
6. Area’s Under an Affine Transformation
Given an affine transformation as a matrix M,
7. Every Affine Transformation is Composed of Elementary Operations
Every affine transformation can be constructed by a composition of elementary operations (see below). That is,
For a 2D affine transformation M. In 3D,
Euler’s theorem: Any rotation (or sequence of rotations) about a point is equivalent to a single rotation about some coordinate axis through that point. Pages 221-223 of Hill give a detailed explanation of this, as well as the equations to go from one form to the other.
W2V (Window to Viewport Mapping)
A simplified OpenGL pipeline applies the modelview matrix, projection matrix, clipping, then the viewport matrix. The viewport matrix is the window to viewport map.
The window coordinate system is somewhere on the projection plane. These coordinates need to be mapped to the viewport (the area on the screen)
F.S. Hill, et al. (2006). Computer Graphics using OpenGL. Second Ed.