Title: Dr' Jinxiang Chai
1CPSC 441 Computer Graphics3-D Viewing
2Review
- 2D Coordinate transform
- Composite transformation
- 3D transformation
- Required readings HB 5-9 to 5-17
3Review 2D Coordinate Trans.
- Transform object description from to
p
4Review 2D Coordinate Trans.
- Transform object description from to
p
3
5Review Composite 2DTrans.
- Whats the world coordinate of A ?
A
World coordinate frame
6Review 3D Transformation
- Very similar to 2D transformation
3D translation
3D Scaling
7Review 3D Rotation
- Transformation matrix for rotating about an
arbitrary axis is more complex
83D Transformation
- Rotation about z
- Rotate about y
- Rotate about x
y
x
z
7
9Review Composite 3D Trans.
8
10Outline
- 3D Viewing
- Required readings HB 7-1 to 7-10
- Compile and run the codes in page 388
9
11Taking Pictures Using A Real Camera
- Steps
- - Identify interesting objects
- - Rotate and translate the camera to a desire
camera viewpoint - - Adjust camera settings such as focal length
- - Choose desired resolution and aspect ratio,
etc. - - Take a snapshot
12Taking Pictures Using A Real Camera
- Steps
- - Identify interesting objects
- - Rotate and translate the camera to a desire
camera viewpoint - - Adjust camera settings such as focal length
- - Choose desired resolution and aspect ratio,
etc. - - Take a snapshot
- Graphics does the same thing for rendering an
image for 3D geometric objects
133D Geometry Pipeline
Rotate and translate the camera
View space
World space
Object space
Focal length
Aspect ratio resolution
Normalized project space
Image space
12
143D Geometry Pipeline
- Before being turned into pixels by graphics
hardware, a piece of geometry goes through a
number of transformations...
Model space (Object space)
153D Geometry Pipeline
- Before being turned into pixels by graphics
hardware, a piece of geometry goes through a
number of transformations...
World space (Object space)
163D Geometry Pipeline
- Before being turned into pixels by graphics
hardware, a piece of geometry goes through a
number of transformations...
Eye space (View space)
173D Geometry Pipeline
- Before being turned into pixels by graphics
hardware, a piece of geometry goes through a
number of transformations...
Normalized projection space
183D Geometry Pipeline
- Before being turned into pixels by graphics
hardware, a piece of geometry goes through a
number of transformations...
Image space, window space, raster space, screen
space, device space
193D Geometry Pipeline
View space
World space
Object space
Normalized project space
Image space
203D Geometry Pipeline
Translate, scale rotate
World space
Object space
glTranslate(tx,ty,tz)
213D Geometry Pipeline
Translate, scale rotate
Object space
World space
glScale(sx,sy,sz)
223D Geometry Pipeline
Translate, scale rotate
Object space
World space
Rotate about r by the angle
glRotate
233D Geometry Pipeline
View space
World space
Object space
Normalized project space
Image space
Screen space
243D Geometry Pipeline
- Now look at how we would compute the world-gteye
transformation
View space
World space
253D Geometry Pipeline
- Now look at how we would compute the world-gteye
transformation
Rotatetranslate
View space
World space
26Camera Coordinate
- Canonical coordinate system
- - usually right handed (looking down z
axis) - - convenient for project and clipping
27Camera Coordinate
- Mapping from world to eye coordinates
- - eye position maps to origin
- - right vector maps to x axis
- - up vector maps to y axis
- - back vector maps to z axis
28Viewing Transformation
- We have the camera in world coordinates
- We want to transformation T which takes object
from world to camera
29Viewing Transformation
- We have the camera in world coordinates
- We want to transformation T which takes object
from world to camera - Trick find T-1 taking object from camera to
world
30Viewing Transformation
- We have the camera in world coordinates
- We want to transformation T which takes object
from world to camera - Trick find T-1 taking object from camera to
world
?
31Review 3D Coordinate Trans.
- Transform object description from to
p
32Review 3D Coordinate Trans.
- Transform object description from to
p
31
33Review 3D Coordinate Trans.
- Transform object description from camera to
world
34Viewing Transformation
- Trick find T-1 taking object from camera to
world - - eye position maps to origin
- - back vector maps to z axis
- - up vector maps to y axis
- - right vector maps to x axis
35Viewing Transformation
- Trick find T-1 taking object from camera to
world -
HB equation (7-4)
36Viewing Trans gluLookAt
- Mapping from world to eye coordinates
-
gluLookAt (x0,y0,z0,xref,yref,zref,Vx, Vy,Vz)
HB equation (7-1)
373D Geometry Pipeline
3D-3D viewing transformation
World space
View space
38Projection
- General definition
- transform points in n-space to m-space (mltn)
- In computer graphics
- map 3D coordinates to 2D screen coordinates
39Taxonomy of Projections
40Taxonomy of Projections
41Parallel Projection
- Center of projection is at infinity
- Direction of projection (DOP) same for all
points
42Orthographic Projection
- Direction of projection (DOP) perpendicular to
view plane
43Orthographic Projection
- Direction of projection (DOP) perpendicular to
view plane
44Oblique Projection
- DOP not perpendicular to view plane
A
A
O
45Oblique Projection
- DOP not perpendicular to view plane
A
A
O
46Properties of Parallel Projection
- Not realistic looking
- Good for exact measurement
- Are actually affine transformation
- - parallel lines remain parallel
- - ratios are preserved
- - angles are often not preserved
- Most often used in CAD, architectural drawings,
etc. where taking exact measurement is important
47Perspective Projection
- Maps points onto view plane along projectors
emanating from center of projection (COP)
48Perspective Projection
- Maps points onto view plane along projectors
emanating from center of projection (COP)
Whats relationship between 3D points and
projected 2D points?
47
49Camera-gtScreen
- Remember Object-gtcamera-gtscreen
50Camera-gtScreen
- Remember Object-gtcamera-gtscreen
- Screen is z-d plane for some constant d
49
51Camera-gtScreen
- Remember Object-gtcamera-gtscreen
- Screen is z-d plane for some constant d
- Coordinates of origin of screen is (0,0,-d)
50
52Camera-gtScreen
- Remember Object-gtcamera-gtscreen
- Screen is z-d plane for some constant d
- Coordinates of origin of screen is (0,0,-d)
- Its x and y axes is parallel to the x and y axes
of eye coordinate system
51
53Camera-gtScreen
- Remember Object-gtcamera-gtscreen
- Screen is z-d plane for some constant d
- Coordinates of origin of screen is (0,0,-d)
- Its x and y axes is parallel to the x and y axes
of eye coordinate system - All these coordinates are in camera space now
52
54Camera-gtScreen
- Consider the projection of a point on the camera
plane
55Camera-gtScreen
- Consider the projection of a point on the camera
plane
By similar triangles, we can compute how much the
x and y coordinates are scaled
56Camera-gtScreen
- Consider the projection of a point on the camera
plane
By similar triangles, we can compute how much the
x and y coordinates are scaled
57Homogeneous Point Revisited
- Remember how we said 2D/3D geometric
transformations work with the last coordinate
always set to one - What happens if the coordinate is not one
- We divide all coordinates by w
If w1, nothing happens Sometimes, we call this
division step the perspective divide
58The Perspective Matrix
- Now we can rewrite perspective projection
equation as a matrix equation
59The Perspective Matrix
- Now we can rewrite perspective projection
equation as a matrix equation
58
60The Perspective Matrix
- Now we can rewrite perspective projection
equation as a matrix equation
After the division by w, we have
61Viewing Angle
- An alternative to specifying the distance between
COP and PP is to specify viewing angle
Given the height of the image h and ? , what is
d?
62Viewing Angle
- An alternative to specifying the distance between
COP and PP is to specify viewing angle
Given the height of the image h and ? , what is
d?
63Viewing Angle
- An alternative to specifying the distance between
COP and PP is to specify viewing angle
Given the height of the image h and ? , what is
d?
64Viewing Angle
- An alternative to specifying the distance between
COP and PP is to specify viewing angle
Given the height of the image h and ? , what is
d?
65Viewing Angle
- An alternative to specifying the distance between
COP and PP is to specify viewing angle
Given the height of the image h and ? , what is
d?
What happens to d as ? increases (keep d
constant)?
66Vanishing Points
- What happens to parallel lines they are not
parallel to the projection plane?
67Vanishing Points
- What happens to parallel lines they are not
parallel to the projection plane? - The equation of the line
68Vanishing Points
- What happens to parallel lines they are not
parallel to the projection plane? - The equation of the line
- After perspective transformation, we have
69Vanishing Points (cont.)
- After perspective transformation, we have
- Divided by w
- Letting t go to infinity
70Vanishing Points
- What happens to parallel lines they are not
parallel to the projection plane? - The equation of the line
71Vanishing Points
- What happens to parallel lines they are not
parallel to the projection plane? - The equation of the line
- How about the line
72Vanishing Points
- What happens to parallel lines they are not
parallel to the projection plane? - The equation of the line
- How about the line
73Vanishing Points
- What happens to parallel lines they are not
parallel to the projection plane? - The equation of the line
- How about the line
Same vanishing point!
74Vanishing Points
- What happens to parallel lines they are not
parallel to the projection plane? - Each set of parallel lines intersect at a
vanishing point on the PP
75Vanishing Points
- What happens to parallel lines they are not
parallel to the projection plane? - Each set of parallel lines intersect at a
vanishing point on the PP - How many vanishing points are there?
76Vanishing Points
- What happens to parallel lines they are not
parallel to the projection plane? - Each set of parallel lines intersect at a
vanishing point on the PP - How many vanishing points are there?
77Properties of Perspective Proj.
- Perspective projection is an example projective
transformation - - lines maps to lines
- - parallel lines do not necessary remain
parallel - - ratios are not preserved
78Properties of Perspective Proj.
- Perspective projection is an example projective
transformation - - lines maps to lines
- - parallel lines do not necessary remain
parallel - - ratios are not preserved
- One of advantages of perspective projection is
that size varies inversely proportional to the
distance-looks realistic
79Properties of Perspective Proj.
- Perspective projection is an example projective
transformation - - lines maps to lines
- - parallel lines do not necessary remain
parallel - - ratios are not preserved
- One of advantages of perspective projection is
that size varies inversely proportional to the
distance-looks realistic - We can not judge distances exactly as we can
with parallel projection
803D Geometry Pipeline
View space
World space
Object space
Normalized project space
Image space
Screen space
81Perspective Projection Volume
- The center of projection and the portion of
projection plane that map to the final image form
an infinite pyramid. The sides of pyramid called
clipping planes - Additional clipping planes are inserted to
restrict the range of depths
82Normalized Perspective-Projection
Normalized project space
View space
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)
81
83Normalized Perspective-Projection
B(xwmax,ywmax,zfar)
A(xwmin,ywmin,znear)
View space
84Normalized Perspective-Projection
B(1,1,1)
B(xwmax,ywmax,zfar)
A(-1,-1,-1)
A(xwmin,ywmin,znear)
Normalized project space (left-handed)
View space (right-handed)
A maps to A, B maps to B Keep the directions of
x and y axes!
85Normalized Perspective-Projection
B(1,1,1)
B(xwmax,ywmax,zfar)
A(-1,-1,-1)
A(xwmin,ywmin,znear)
HB equation (7-40)
86Normalized Perspective-Projection
B(1,1,1)
B(xwmax,ywmax,zfar)
A(-1,-1,-1)
A(xwmin,ywmin,znear)
Normalized project space
View space
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)
873D Geometry Pipeline
View space
World space
Object space
Normalized project space
Image space
88Viewport Transformation
B(1,1,1)
B(xvmax,yvmax,1)
Normalized project space
A(xvmin,yvmin,0)
A(-1,-1,-1)
Image space
Normalized project space
89Viewport Transformation
B(1,1,1)
B(xvmax,yvmax,1)
Normalized project space
A(xvmin,yvmin,0)
A(-1,-1,-1)
Image space
Normalized project space
HB equation (7-42)
90Viewport Transformation
(xmin,ymin)
Image space-.gtImage space
gluViewport(xmin, ymin, width, height)
91Summary 3D Geometry Pipeline
View space
World space
Object space
Normalized project space
Image space
92Next Lecture
- Hierarchical Models
- Animation with motion capture data
- - skeletal model (.asf)
- - motion data (.amc)
- Required readings
- - HB chapter 14,
- - OpenGL Programming Guide, chapter 3