# CS488 - Introduction to Computer Graphics - Lecture 7

## Review

1. Transformation Matrices
2. Rotation
3. Transposition

## Non-rigid Transformations

#### Scaling

Three interpretations

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

## Device Transformations

#### Windows

On the view plane

On the device

#### Normalized Device Coordinates

For the device, obviously

## Clipping

What is it?

#### Representations of Lines

1. Parametric
2. 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)
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).
• 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

1. ( R - P ) . n
2. ( S - P ) . 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 ) . 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?