CS488 - Introduction to Computer Graphics - Lecture 6
Comments and Questions
- View frame.
Reprise: Matrix Representations of Affine Transformations
Write a general point in terms of its coordinates in two different
orthonormal frames.
- P = x i + y j + z k + O = x' i' + y' j' + z' k' + O'
- ( x, y, z ) and ( x', y', z' ) are the two sets of coordinates.
- ( i, j, k, O ) and ( i', j', k', O' ) are the two frames.
- If any three of these are known we can find the fourth.
Example. Find ( x', y', z' )
- x' i' + y' j' + z' k' = x i + y j + z k + (O - O')
Notice that this is a vector equation. 0 = 0 in the fourth coordinate
comes for free!
- Then, taking the dot product with i': x' = x (i . i') + y (j . i') + z
(k . i') + (O - O') . i'
This is an ordinary linear algebraic equation.
There are two other equations like this one, produced by j' and k'.
See how nice it is to have an orthonormal frame!
- Write the three algebraic equations together as a matrix
multiplication.
/ \ / \ / \
| i.i' j.i' k.i' (O-O').i' | | x | | x' |
| i.j' j.j' k.j' (O-O').j' | | y | = | y' |
| i.k' j.k' k.k' (O-O').k' | | z | | z' |
\ / \ / \ /
- What about the fourth row of the matrix?
Points have the fourth coordinate 1, vectors 0.
Regardless of the coordinates points should stay points, vectors
vectors.
Only the row ( 0, 0, 0, 1 ) makes it happen.
This method works fine when we know the frames in terms of each other - or
in terms of another frame - but not when we want to derive the matrix from a
geometrical manipulation.
Another Take on Affine Transformations
`The longest journey starts with but a single step.' What does this
mean?
- Tj = Tsn ... Ts2 Ts1
- Any transformation can be
constructed from a sequence of more elementary transformations.
Is there a small set of simple transformations from which all
transformations can be constructed?
- Yes!!
- Should we thank heaven for making it so?
- Or geometers for discovering and exploring it?
Example
Translation is simple; rotation about a basis vector is simple. But
rotation about an arbitrary axis is complex.
Construct rotation about an aribitrary axis from translation and rotation
about a basis vector.
- Translate the axis of rotation so that it passes through the
origin.
- Rotate the axis of rotation - possibly twice (Why?) - to make it lie
along a coordinate axis.
- Rotate by the specified angle.
- Invert the axis rotation.
- Invert the translation.
Specific Matrices You should Know
Transforming a the Coordinates of a Point
- Inverse of transforming a frame
- P = F pF = F' pF' = F Tinv T pF
- pF' = T pF are the transformed coordinates
- F' = F Tinv is the transformed frame
Transforming a Frame
- Inverse of transforming a point
Rigid Transformations
These three transformations - translation, rotation, reflection - have a
special property
- They don't change the size or shape of the object.
All rigid transformations can be constructed from them.
- You should understand this geometrically.
Translation
Add a vector to a point
/ \ / \ / \
| 1 0 0 ax | | x | | x + ax |
| 0 1 0 ay | | y | = | y + ay |
| 0 0 1 az | | z | | z + az |
| 0 0 0 1 | | 1 | | 1 |
\ / \ / \ /
- To invert change the sign of a. Check for yourself.
No effect on vector. Check for yourself.
Rotation
To specify a rotation you need
- an axis of rotation
- an angle of rotation
- Ra, thetaa( P )
Three basic rotations encompass all rotations
- geometrical demonstration
/ \ / \ / \
| cos(t) -sin(t) 0 0 | | x | | x*cos(t) - y*sin(t) |
| sin(t) cos(t) 0 0 | | y | = | x*sin(t) + y*cos(t) |
| 0 0 1 0 | | z | | z |
| 0 0 0 1 | | 1 | | 1 |
\ / \ / \ /
Example: polar coordinates
- one distance specifies distance from the origin
- two angles specify direction with respect to the coordinate frame:
usually \theta, \phi
- \theta: angle from the z-axis
- \phi: angle around the z-axis
Reflection
To specify a reflection you need
- a plane across which the reflection occurs
- suppose the plane is the yz-plane.
/ \ / \ / \
| -1 0 0 0 | | x | | -x |
| 0 1 0 0 | | y | = | y |
| 0 0 1 0 | | z | | z |
| 0 0 0 1 | | 1 | | 1 |
\ / \ / \ /
Non-rigid transformations
These three transformations - translation, rotation, reflection - have a
special property
- Rigid body transformations.
- They don't change the size or shape of the object.
Other affine transformations don't have this property
Scaling
Three interpretations
- Movement of a point
- Change of units
- Change of frame
The last two are really the same, and they cause trouble. Why?
Shear
Device Transformations
Windows
On the view plane
Viewports
On the device
Normalized Device Coordinates
For the device, obviously
Clipping
What is it?
Representations of Lines
- Parametric
- Implicit
- n - unit vector normal to line
- For L(t) = P + t ( Q - P )
- n . ( Q - P ) = 0
- If P is any point on the line then d( R ) = ( R - P ) . n is the
signed distance to the line
- Checks (for homework)
- If R is on the line then d( R ) = 0.
- If R is off the line then d( R ) != 0.
Clip a Point against a Half-space.
Representation of a Half-space.
- Use the implicit representation of a line (P, n).
- Let the direction of the normal vector point to the inside.
Calculate ( R - P ) . n
- If > 0, inside.
- If < 0, outside.
- If = 0, on the line.
Clip a Line Segment to a Half-space.
The line segment
- L(t) = R + t ( S - R ), 0 < t < 1.
Test if each of R and S are inside. Calculate
- ( R - P ) . n
- ( S - P ) . n
There are three cases
- Both inside: keep the segment as is.
- Both outside: discard the segment.
- One inside, one outside: the segment crosses the boundary of the
half-space.
- Calculate the intersection
- ( L(t) - P ) . n = 0.
- t = { ( P - R ) . n } / { ( S - R ) . n }
- Optimize ??
- t = { ( P - R ) . n } / { ( S - P ) . n - ( R - P ) . n }
- Replace one of the end points by L(t), (Which one?)
Clip a Line Segment to a Rectangle
Straightforward, BUT what if the line segment crosses a corner?
Return to: