Viewing and Projections
Viewing and Projections
What are Projections?
Classical Projections
Planar Geometric Projections
• Standard projections project onto a
plane
• Projectors are lines that either:
• Converge at center of projection
• Are parallel
• Preserve lines but not angles
Remember Art Class?
Projection Taxonomy
planar geometric projections
parallel
perspective
1 point
multiview axonometric oblique
orthographic
isometric
dimetric
trimetric
2 point
3 point
Orthographic Projection
Projectors orthogonal to projection surface
Orthographic Uses
Preserves shape and
measurements
(great for CAD)
Need isometric to see
what’s hidden
Default Camera Projection
Orthographic is default
pp = Mp
xp = x
yp = y
zp = 0
wp = 1
⎡1
⎢0
M= ⎢
⎢0
⎢
⎣0
0 0 0⎤
1 0 0⎥⎥
0 0 0⎥
⎥
0 0 1⎦
Projecting onto a Screen
Define area of screen and clip coordinates
glOrtho(left,right,bottom,top,near,far)
Normalized Device Coordinates
Transformed clipped coordinates to
normalized device coordinates (NDC)
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
1.0);
Orthographic Eye to NDC
• Move center to origin
• Scale to have sides of length 2
⎡
2
⎢
⎢ right − left
⎢
⎢
0
⎢
⎢
0
⎢
⎢
⎢
0
⎣
0
0
2
top− bottom
0
0
2
near − far
0
0
⎤
⎥
⎥
top+ bottom ⎥
−
⎥
top− bottom ⎥
far + near ⎥
−
⎥
far − near ⎥
⎥
1
⎦
right + left
−
right − left
Perspective Projection
• Converge at point
along projection
(vanishing
point)
• Multiple vanishing
points in multipoint
perspective
Projective Space
• W provides extra dimension to (x, y, z)
coordinate space
• Acts as a scaling value to represent
distance from projector
• Larger w values correspond to more
distance from viewer
Simple Perspective
• Center of projection at origin
• z is projection plane
xp =
x
z/ d
yp =
y
z/ d
zp = d
Homogeneous Form
consider Mp = p’ where:
⎡1
⎢0
⎢
⎢0
⎢
⎣0
0 0
1 0
0 1
0 1/ d
0⎤
⎥
0⎥
0⎥
⎥
0⎦
⎡ x⎤
⎢ y⎥
⎢ ⎥
⎢ z⎥
⎢ ⎥
⎣1 ⎦
=
⎡ x ⎤
⎢ y ⎥
⎢
⎥
⎢ z ⎥
⎢
⎥
⎣z/ d⎦
Apply perspective division (convert
coordinate back to w=1)
p’ = (dx/z, dy/z, d, 1)
Perspective Projection
glFrustum(left,right,bottom,top,near,far)
Projecting onto the Near Plane
Map eye space point (xe, ye, ze) to near
plane point (xp, yp, zp)
Perspective Normalization
Clipping
N=
⎡
⎢
⎢
⎢
⎢
⎣
⎤
⎥
⎥
⎥
⎥
0 0 −1 0 ⎦
1 0
0 1
0 0
0
0
α
0
0
β
α=
β=
near + far
far − near
2near ∗ far
near − far
near plane is mapped to z = -1
far plane is mapped to z = 1
sides are mapped to x = ± 1, y = ± 1
Symmetric Viewing Volume
When right = -left and top = -bottom:
General Frustum Transform
⎡ 2n
⎢r − l
⎢
⎢ 0
⎢
⎢ 0
⎢
⎢ 0
⎣
0
2n
t −b
0
0
r +l
r −l
t +b
t −b
− ( f + n)
f −n
−1
⎤
0 ⎥
⎥
0 ⎥
⎥
− 2 fn ⎥
f −n⎥
0 ⎥⎦
Note about Deprecation
glOrtho and glFrustum are deprecated as
of OpenGL 3.0
Replacements:
glm::glOrtho
glm::glFrustum
In-Class Exercise
• Consider glFrustum(-4, 4, -3, 3, 5,
80) and glOrtho(-4, 4, -3, 3, 5,
80)
• Construct these projection matrices
• Apply these matrices to points:
• p1 = (3, 2, 20)
• p2 = (3, 2, 3)
• p3 = (-2, -4, 10)
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising