CS488 - Introduction to Computer Graphics - Lecture 6
Comments and Questions
- View frame.
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
- The set of points L(t) on the line is given by L(t) = P + t ( Q - P
)
- Implicit
- n - unit vector normal to line (Q, P); that is, n \dot (Q - P) = 0
- Any point L on the line satisfies n . ( L - P ) = 0.
- If P is any point on the line then d( R ) = ( R - P ) . n is the
signed distance to the line
Why?
- Draw the line (Q, P) and the point R.
- Place a point S on the line so that R-S is perpendicular to Q -
P..
- If \theta is the angle between R - S and R - P then (R - S)
\dot (R - P) = |(R - S)| |(R - P)| cos(\theta)
- But R - S = |R - S| * (sign) * n
- Thus, n \dot (R - P) = (sign) * |R - P| * cos(\theta)
Clip a Point against a Line
This means: which side of a line Q - P is a point R, above it or below
it?
Clip a Point against a Half-space.
Representation of a Half-space.
- Use the implicit representation of a plane (P, n).
- Let the direction of the normal vector point to the inside.
Calculate d = ( R - P ) . n
- If d > 0, inside.
- If d < 0, outside.
- If d = 0, on the line.
The direction of n has been chosen to point towards the inside.
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 = { - ( R - P ) . n } / { ( S - P ) . n - ( R - P ) . n }
- Is this really an optimization with todays compilers?
Clip a Line Segment to a Rectangle
Define a rectangle as a collection of half spaces, then it is
straightforward. Really?
- What if the line segment crosses a corner?
Perspective Projection
For a comprehensive introduction to perspective projection, more than most
of you want to know, look at this pdf.
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.
Perspective Projection from 1D to 1D
The 1D Cartesian Space.
Projection from a 1D space to a 1D space.
- We draw it in two dimensions (Why?)
- Pencil of lines through a projection point: all points on a line are
the `same' point.
- Affine transformations from 1D to 1D
- What can an affine transformation do in 1D? Translate, reflect,
scale.
- Projection points at infinity translate.
- A projection point between the origins reflects.
- Projection points on the line that joins the origins, and outside
the lines, scale.
- What do other projection points do?
What does this type of projection have to do with computer graphics?
- Perspective projection maps 3D world space to the 2D viewplane.
- What happens if the projection point is on one of the lines?
Return to: