# 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

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?
1. Ri,90( P ) rotates the y-axis into the z-axis
2. Rk,90( P ) rotates about the z-axis (formerly the y-axis)
3. Ri,-90( P ) rotates the z-axis (formerly the y-axis) back to the y-axis

## Non-rigid transformations

#### Scaling

Three interpretations

1. Change of units
2. Change of frame
3. Movement of point

# Clipping

What is it?

#### Representations of Lines

1. Parametric: y = mx + b, z = nx + c
2. 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)
1. If R is on the line then d( R ) = 0.
2. 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

1. d(R) = ( R - P ) \dot n
2. d(S) = ( S - P ) \dot n

There are three cases

1. Both inside: keep the segment as is.
2. Both outside: discard the segment.
3. 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?