# CS488 - Introduction to Computer Graphics - Lecture 7

## Comments and Questions

## Review

- Transformation Matrices
- Rotation
- Transposition

## Non-rigid Transformations

#### Scaling

Three interpretations

- Change of units
- Movement of point
- Change of frame

#### 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: