# CS488 - Introduction to Computer Graphics - Lecture 10

## Comments and Questions

## Review

- Non-rigid transformations
- Normalized Device Coordinates

## Clipping

What is it?

#### Representations of Lines

- Parametric
- Implicit
- n - unit vector normal to line
- For the line L(t) = P + t ( Q - P ),
- the normal is defined by 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.
- How do you figure out which side of the line is positive?

#### 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 that bounds the half-space.

#### 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 }
- What will an optimizing compiler do?

- 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?

## Perspective Projection

What is a projection?

- a `linear' mapping of points to points
- `linear' in the sense that lines map to lines
- not `linear' in the sense that a projection automatically commutes
with addition
- Affine transformations are linear in both senses

- based on a centre of projection
- which might be at infinity

- relevance to computer graphics?
- importance of two dimensions in everyday life. (Lots here to think
about!)

Projective transformations are a superset of affine transformations.

- They do not preserve ratios of distance.
- They do not preserve affine combinations.
- They do not map vectors.
- They do preserve the cross ratio.

Show 1D transformation on the board

- Illustration in 2D. What does this mean? (Hint. homogeneous
coordinates)
- Projection point on one of the lines.
- Relevance of the intersection point of two lines.
- How the transformation changes as the projection point moves
around.

#### Return to: