CS488 - Introduction to Computer Graphics - Lecture 7
Affine Transformations in Practice
Rigid Transformations
Rotation
To specify a rotation you need
- an axis of rotation, a
- an angle of rotation, t
- Ra, t( P )
Three basic rotations encompass all rotations geometrical demonstration
- about the x-axis
- about the y-axis
- about the z-axis
You know the basic matrix for 2D rotation
/ \
| cos(t) sin(t) |
| |
| -sin(t) cos(t) |
\ /
Generalize it into three dimensions
But only two are independent
- E.g., Rj,90( P ) = Ri,-90( P ) Rk,90( P ) Ri,90( P )
- Why does this work?
- Ri,90( P ) rotates the y-axis
into the z-axis
- Rk,90( P ) rotates about the
z-axis (formerly the y-axis)
- Ri,-90( P ) rotates the z-axis
(formerly the y-axis) back to the y-axis
Non-rigid transformations
Scaling
Three interpretations
- Change of units
- Change of frame
- Movement of point
Others
Clipping
What is it?
Representations of Lines
- Parametric: y = mx + b, z = nx + c
- Implicit, L(t) = P + t v = P + t ( Q - P )
- 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).
- P on the separating
plane
- n perpendicular to the
separating plane
- Let the direction of the normal vector point to the inside.
Calculate d = ( R - P ) \dot n
- If d > 0, inside.
- If d < 0, outside.
- If d = 0, on the line.
Clip a Line Segment to a Half-space.
The line segment
- L(t) = R + t ( S - R ), 0 < t < 1.
- R is at one end of the line
segment
- S is at the other end
Test if each of R and S are inside. Calculate
- d(R) = ( R - P ) \dot n
- d(S) = ( S - P ) \dot 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 ) \dot n = 0.
- t = { ( P - R ) \dot n } / { ( S - R ) \dot n }
- Optimize (??)
- t = { ( P - R ) \dot n } / { ( S - P ) \dot n - ( R - P )\dot. n }
- Replace one of the end points by L(t), (Which one?)
Clip a Line Segment to a Rectangular Parallellopiped
Straightforward, BUT what if the line segment crosses a corner?
Two Good Examination Questions
Return to: