Professional Documents
Culture Documents
Projection Lec 8up
Projection Lec 8up
• Projection in computer graphics. • Gets a bit mathematical (but not for a while).
• Viewing in OpenGL.
3D world
Project onto Transform to
coordinate Clip against 2D device
projection 2D device
output view volume coordinates
plane coordinates
primitives
pro pro
jecti jecti
A on C
on
plan
e
plan
e • Convert an nD coordinate system into a mD coordinate system:
C*
in computer graphics n = 3 and m = 2.
A*
B D
s
• We consider planar geometric projections – we project onto a
rs B* tor
to jec
pr
o jec pro
D* plane.
to
inf
centre of projection
• Projections can be visualised using projectors which emanate
ini
ty
• Perspective foreshortening is important to realism but results in • The centre of projection is generally at a finite distance from the
distortion of angles, distances and parallel lines. projection plane but is sometimes defined at infinity.
• Parallel projections also distort angles, but maintain parallelism • Easy to implement (if not understand) using homogeneous
and distances. coordinates.
• We need to define the projection plane – how can this be done? • Most simple is to define a point in the projection plane, and then
two vectors, one for up and one for across.
pro pro
jecti jecti
on A on C
plan plan
e e
• This allows us to define any (all) points in the plane.
C*
A*
B D
• For computer graphics we normal give a point, a vector to
to
rs B*
ec
tor
s
define up and a normal vector to the plane (which is the cross
o jec proj D*
pr product of the up and across vectors).
to
inf
centre of projection
ini
graphics.
Projection
plane
z
Projection plane
x x
Center of
projection
z x-axis vanishing point z-axis vanishing point
Projection
plane
Center of projection
normal
• Parallel orthographic projections have the direction of the • Axonometric orthographic projections are parallel projections
projection parallel to the normal to the projection plane: that use projection planes that are not normal to the principal
Projection
axes.
plane
(top view)
Projection
Projectors for plane
side view
Projectors y
for top view Projector
Projection
plane
Projectors for (side view) Projection-
front view plane x
Projection
normal
plane
(front view) z
• In oblique projection the projection plane normal and direction of • OpenGL viewing definition uses the camera analogy.
projection differ.
• Two matrices define the total projection:
Projection y
plane
• GL PROJECTION defines the projection using the matrices:
M Sper Hpar as given in the notes.
• Define the viewing window (xmin, ymin and xmax, ymax), and the
Projector x
z near and far clipping planes.
• The other matrix to set is the GL MODELVIEW matrix which • Easy to get lost in space: keep the far clipping plane to a large
controls both the objects and the view. value – changing the near clipping plane changes the degree of
perspective distortion.
• Use gluLookAt with the eye, location to look at and up vector to
define the view of the object. • Use asymmetric (xmin, ymin and xmax, ymax) to achieve false
perspective – make VPN non-parallel to DOP.
• This is like the matrices Spar Tpar as given in the notes.
• Start with a large front clipping plane: (xmin, ymin and
• Think of this like aiming the camera. xmax, ymax) – then focus in on the object.
• Set the viewport using glViewPort and give the origin and width
/ height (keep the same as the aspect ratio of the front clipping
plane.
• The OpenGL viewing pipeline looks like: • Can also use parallel projections: use glOrtho to set the
perspective projection matrix.
x division window x’
model
y projection to y’
view /w
z
matrix
matrix viewport • The model view matrix is set in the same way as before.
w Screen
Coordinates
Canonical
World Eye Clip
Coordinates Coordinates Coordinates
View • Use glLoadMatrix to define our own projection matrices
Volume
(masochists only).
• For both projection and model view matrices use glMatrixMode to
• Beware the difference between modelling and viewing
define which to use and then don’t forget to initialise them using
transformations.
glLoadIdentity.
• Viewing transformations are always set first in the code, since
they are applied last to the animated models.
Summary