CS488 - Introduction to Computer Graphics - Lecture 6
Transformations in Affine Spaces
Comments and Questions
- Assignment 0
- Assignment 1, office hours
Affine Spaces (review)
Space means closed under ...
- Vector space
- Set of vectors
- Closed under vector addition (+1), scalar multiplication
- Bases
- Infinite number
- All have the same cardinality
- Know, from first year, how to transform one basis to another
Plus, a set of points
- Closed under point/vector addition (+2)
- Bases must add a point, any point
- Transform one basis to another
- Add a vector to the point
- And use vector space transforms
Special properties
- Affine combinations
- Affine transformations: linear under
- vector/vector addition: T(v1 +1
v2) = T(v1) +1 T(v2)
- point/vector addition: T(P +2
v) = T(P) +2 Y(v)
form groups. (Thanks, Felix Klein)
Euclidean Space
An affine space plus a metric, d(P1, P2), that has translational
invariance
- Metric is symmetric by definition
- also non-negative and obeying the triangle inequality.
- Translational symmetry means: d(P1, P2) = d(P1 +2 v, P2 +2 v).
The familiar dot product (defined on vectors, Why?) is your baby.
- d(P1, P2) = ( P1 -2 P2 ) /dot ( P1
-2 P2 ) = | P1 -2 P2 |
- This gives you what Euclid was able to do with a compass, and more.
The dot product also defines angles between vectors.
- cos(s) = v1 \dot v2 / (|v1| |v2|),
- s is the angle between v1 and v2.
- This is part of the `more' we got than compass.
Cartesian Space
A Euclidean space plus a (usually orthonormal) frame.
- The frame is ( i, j, k, O ).
- ( i, j, k ) is a set of basis vectors that normally has two properties
- orthogonality: i \dot j = j \dot k = k \dot i = 0.
- normalization: |i| = |j| = |k| = 1.
Using the frame (often called `standard' or `distinguished' ) we can write
uniquely
- any vector as v =1 ( x, y, z, 0 )
\dot ( i, j, k, O ) =1 x *1 i +1
y *1 j +1 z *1
k, and
- any point as P =2 ( x, y, z, 1 )
\dot ( i, j, k, O ) =2 ( x *1 i +1
y *1 j +1 z *1
k ) +2 O
- ( x, y, z, 1 ) and ( x, y, z, 0 ) are called the `coordinates' of the
point or vector.
- Note that coordinates are defined wrt a frame: without a specific frame
they are meaningless.
Affine Transformations in Cartesian Spaces
The general idea is that we apply a transformation to a point to position
it.
There are two ways to see this process
One Point, Two Frames
- P = x i + y j + z k + O; P' = x' i' + y' j' + z' k' + O'
- P' = P
- Express the second frame in terms of the first.
i = T(i') = a00i' + a01j' + a02k', etc.
O = T(O') = a30 i' + a31 j' + a32 k' + O'.
- Then collect terms and solve for x', y', z'.
x' = x a00 + y a10 + x a20 + a30, etc
- Thus
(x', y', z', 1) = U(x,y,z,1) where U is the transpose of T
This tells you the coordinates the same point in a different frame.
Two Points, One Frame
- P = x i + y j + z k + O; P' = x' i' + y' j' + z' k' + O'
- P' = T'(P)
- Express the second frame in terms of the first.
i' = T'(i) = b00 i + b01 j + b02 k, etc.
O' = T'(O) = b30 i + b31 j + b32 k + O.
- Then collect terms and solve for x', y', z'.
- Thus,
(x, y, z, 1) = U'(x, y, z, 1), where U' is the transpose of T'
This tells you the coordinates the transformed point in the original
frame.
It's Pretty Easy to See that
- T' is the inverse of T: i' = T(i) = T(T'(i')), etc.
U' is the inverse of U
U' = T, T' = U
- a00 = i \dot i', a01 = i \dot j', etc.: Take the dot product
with i, j, k of equation 3.
Example: Viewport Transformation
Viewplane frame
- Origin, O, at the centre
- i increasing to the right (measured in pixels)
- j increasing up (measured in pixels)
Display frame
- Origin, O', in the upper left corner
- i' increasing to the right (measured in pixels)
- j' increasing down (measured in pixels)
We know where a point in in the viewplane coordinates, and we want to
display it, so we want to know its coordinates in the display frame: i.e. one
point, two frames.
- O' = O + (height/2) * i +(width/2) * j
- i = i'
- j = -j'
- 1 0 0 1 0 h/2
T = 0 -1 0 T' = 0 -1 w/2
h/2 w/2 1 0 0 1
Exercise for the reader: How would this change if the viewplane frame was
measured in centimetres?
View Transformations
Return to the rendering pipeline.
- Several objects positioned in the world
- Frames view
- Each object has its own frame, in terms of which its points
have coordinates.
- Express all object coordinates in a common frame, the modelling
frame.
- Express the modelling frame in terms of the world frame.
- Get coordinates of each object in the world frame.
- Points view
- Each object starts at the origin of the world frame in a
standard orientation, with point coordinates in the world
frame.
- Move the object to the correct position and orientation by
transforming its coordinates.
- The two views give exactly the same result, with slightly different
mathematics, which will be explained later.
- Viewer's eye looks at the world. Possibilities
- Put the eye in the world frame.
- Do high school geometry.
- What a drag!
- Associate a frame, the view frame, with the viewer.
- Find object coordinates in the view frame.
- Drop a coordinate, because you defined the view frame
cleverly.
What happened?
- Point Po in object coordinates.
- Transform Po by T1 to get it into world coordinates: Pw = T1( Po )
- Transform Pw by V to get it into view coordinates: Pv = V( Pw ) = V(
T1( Po ) ) = V T1 Po.
To move the point transform it again.
- Pw = T2 T1 Po
- Pv = V T2 T1 Po
Return to: