Download Computer Graphics - KDD - Kansas State University

Survey
yes no Was this document useful for you?
   Thank you for your participation!

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

Document related concepts

BSAVE (bitmap format) wikipedia , lookup

Free and open-source graphics device driver wikipedia , lookup

Stereoscopy wikipedia , lookup

Waveform graphics wikipedia , lookup

Computer vision wikipedia , lookup

General-purpose computing on graphics processing units wikipedia , lookup

Apple II graphics wikipedia , lookup

Framebuffer wikipedia , lookup

Video card wikipedia , lookup

Tektronix 4010 wikipedia , lookup

Graphics processing unit wikipedia , lookup

Molecular graphics wikipedia , lookup

Perspective projection distortion wikipedia , lookup

2.5D wikipedia , lookup

Transcript
CIS 636
Introduction to Computer Graphics
CG Basics 4 of 8:
Detailed Introduction to Viewing
William H. Hsu
Department of Computing and Information Sciences, KSU
KSOL course pages: http://snipurl.com/1y5gc
Course web site: http://www.kddresearch.org/Courses/CIS636
Instructor home page: http://www.cis.ksu.edu/~bhsu
Readings:
Slides based on Viewing 1-3, http://www.cs.brown.edu/courses/cs123/lectures.htm
Sections 2.6 – 2.7, Eberly 2e – see http://snurl.com/1ye72
OpenGL API Documentation: http://www.opengl.org/documentation/
Lab 2: glFrustum(), gluPerspective() (http://snurl.com/1zt6z)
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Online Recorded Lectures for CIS
636
Introduction to Computer Graphics
 Project Topics for CIS 636
 Computer Graphics Basics (8)
 1. Mathematical Foundations – Week 2
 2. Rasterizing and 2-D Clipping – Week 3
 3. OpenGL Primer 1 of 3 – Week 3
 4. Detailed Introduction to 3-D Viewing – Week 4
 5. OpenGL Primer 2 of 3 – Week 5
 6. Polygon Rendering – Week 6
 7. OpenGL Primer 3 of 3 – Week 8
 8. Visible Surface Determination – Week 9
 Recommended Background Reading for CIS 636
 Shared Lectures with CIS 736 (Computer Graphics)
 Regular in-class lectures (35) and labs (7)
 Guidelines for paper reviews – Week 7
 Preparing term project presentations, demos for graphics – Week 11
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Lecture Outline
 History of Projections
 Normalizing and Viewing Transformations
 Perspective (to Parallel) Transformation
 Kinds of Projections
 Parallel
 Orthographic: top, front, side, other
 Axonometric: isometric, dimetric, trimetric
 Oblique: cavalier, cabinet
 Other
 Perspective: 1-point, 2-point, 3-point
 Viewing in OpenGL
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
From 3-D to 2-D: Orthographic and
Perspective Projection – Part 1
 History
 Geometrical Constructions
 Types of Projection
 Projection in Computer Graphics
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Logical Relationship among
Types of Projections
 Parallel projections used for engineering and architecture because
they can be used for measurements
 Perspective imitates our eyes or camera, looks more natural
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Axonometric Projections
 Same method as multiview orthographic
projections, except projection plane not
parallel to any of the coordinate planes;
parallel lines are equally foreshortened
 Isometric: Angles between all three
principal axes are equal (120º). The same
scale ratio applies along each axis
 Dimetric: Angles between two of the
principal axes are equal; need two scale
ratios
 Trimetric: Angles different between the
three principal axes; need three scale
ratios
 Note: different names for different views,
but all part of a continuum of parallel
projections of the cube; these differ in
where the projection plane is relative to its
cube
dimetric
dimetric
isometric
dimetric
orthographic
Carlbom Fig. 3-8
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Isometric Projection:
Special Case of Axonometric
 Used for:




catalogue illustrations
patent office records
furniture design
structural design
 Pros:
 don’t need multiple views
 illustrates 3D nature of object
 measurements can be made to scale along principal axes
 Cons:
 lack of foreshortening creates distorted appearance
 more useful for rectangular than curved shapes
Example
Construction of isometric projection:
projection plane cuts each principal axis by 45°
Carlbom Fig.2.2
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Oblique Projections
 Projectors are at an oblique angle to the projection plane; view
cameras have accordion housing, used for skyscrapers
 Pros:
 can present the exact shape of one face of an object (can take accurate
measurements): better for elliptical shapes than axonometric projections,
better for “mechanical” viewing
 lack of perspective foreshortening makes comparison of sizes easier
 displays some of object’s 3D appearance
 Cons:
 objects can look distorted if careful choice not made about position of
projection plane (e.g., circles become ellipses)
 lack of foreshortening (not realistic looking)
perspective
oblique
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
View Camera
Source: http://www.usinternet.com/users/rniederman/star01.htm
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Examples of Oblique Projections
(Carlbom Fig. 2-6)
Construction of an oblique
parallel projection
Plan oblique projection of a city
(Carlbom Fig. 2-4)
Front oblique projection of a radio
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Example and Principles:
Oblique View
 Rules for placing projection plane for oblique views
 Projection plane should be set parallel to one of:
 most irregular of principal faces, or one which contains circular
or curved surfaces
 longest principal face of object
 face of interest
Projection plane parallel to circular face
Projection plane not parallel to circular face
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Main Types of Oblique Projections
 Cavalier: Angle between projectors and projection plane is 45º.
Perpendicular faces are projected at full scale
cavalier projection
of unit cube
 Cabinet: Angle between projectors and projection plane is arctan(2) =
63.4º. Perpendicular faces are projected at 50% scale
cabinet projection
of unit cube
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Examples of Orthographic and
Oblique Projections
multiview orthographic
cavalier
cabinet
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Carlbom Fig. 3-2
Computing & Information Sciences
Kansas State University
Parallel Projections: Summary

Assume object face of interest lies in principal plane, i.e., parallel to xy, yz, or zx
planes. (DOP = Direction of Projection, VPN = View Plane Normal)
1) Multiview Orthographic
– VPN || a principal coordinate axis
– DOP || VPN
– shows single face, exact measurements
2) Axonometric
– VPN || a principal coordinate axis
– DOP || VPN
– adjacent faces, none exact, uniformly
foreshortened (as a function of angle between
face normal and DOP)
3) Oblique
– VPN || a principal coordinate axis
– DOP || VPN
– adjacent faces, one exact, others uniformly
foreshortened
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Perspective Projections
 Used for:
 advertising
 presentation drawings for architecture, industrial design, engineering
 fine art
 Pros:
 gives a realistic view and feeling for 3D form of object
 Cons:
 does not preserve shape of object or scale (except where object intersects
projection plane)
 Different from a parallel projection because
 parallel lines not parallel to the projection plane converge
 size of object is diminished with distance
 foreshortening is not uniform
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Vanishing Points [1]
 For right-angled forms whose face normals are perpendicular to the x,
y, z coordinate axes, the number of vanishing points = number of
principal coordinate axes intersected by projection plane
One Point Perspective
(z-axis vanishing point)
z
Three Point Perspective
(z, x, and y-axis vanishing points)
Two Point Perspective
(z, and x-axis vanishing points)
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Vanishing Points [2]
 What happens if same form is turned so that its face normals are not
perpendicular to x, y, z coordinate axes?
•
New viewing situation: cube rotated, face normals
no longer perpendicular to any principal axes
•
Note: unprojected cube depicted here with parallel
projection
•
Although projection plane only intersects one axis
(z), three vanishing points were created
•
Note: can achieve final results which are identical to
previous situation in which projection plane
intersected all three axes
Perspective drawing
of rotated cube
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Vanishing Points and View Point [1]
 We’ve seen two pyramid geometries for understanding perspective
projection:
1.
perspective image is
intersection of a plane with
light rays from object to eye
(COP)
2.
perspective image is result of
foreshortening due to
convergence of some parallel
lines toward vanishing points
 Combining these 2 views:
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Vanishing Points and View Point [2]
 Project parallel lines AB, CD on xy plane
 Projectors from the eye to AB and CD define two planes, which meet
in a line which contains the view point, or eye
 This line does not intersect the projection plane (XY), because parallel
to it. Therefore there is no vanishing point
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Vanishing Points and View Point [3]
 Lines AB and CD (this time with A and C behind projection plane)
projected on xy plane: A’B and C’D
 Note: A’B not parallel to C’D
 Projectors from eye to A’B and C’D define two planes which meet in a
line containing view point
 This line intersects projection plane
 Point of intersection is vanishing point
A
C
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Aspect Ratio





Analogous to size of film used in a camera
Determines proportion of width to height of image displayed on screen
Square viewing window has aspect ratio of 1:1
Movie theater “letterbox” format has aspect ratio of 2:1
NTSC television has aspect ratio of 4:3, HDTV is 16:9
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
View Angle [1]
 Determines amount of perspective distortion in picture
 parallel projection: none
 wide-angle lens: lots
 In a frustum, two viewing angles
 Width and height angles
 We specify Height angle
 Get Width angle from
Aspect ratio * Height angle
 Choosing View angle
 Analogous to photographer choosing a specific type of lens
 e.g., wide-angle or telephoto (narrow angle) lens
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
View Angle [2]
 Lenses made for distance shots often have a nearly parallel viewing angle
and cause little perspective distortion, though they foreshorten depth
 Wide-angle lenses cause a lot of perspective distortion
Resulting pictures
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
“Where’s My Film?”
Real cameras have a roll of film that captures pictures

Synthetic camera “film” is a rectangle on an infinite film plane that contains image of
scene

Why haven’t we talked about the “film” in our synthetic camera, other than mentioning
its aspect ratio?

How is the film plane positioned relative to the other parts of the camera? Does it lie
between the near and far clipping planes? Behind them?

Turns out that fine positioning of Film plane doesn’t matter. Here’s why:
 for a parallel view volume, as long as the film plane lies in front of the scene,
parallel projection onto film plane will look the same no matter how far away film
plane is from scene
 same is true for perspective view volumes, because the last step of computing the
perspective projection is a transformation that stretches the perspective volume
into a parallel volume

In general, it is convenient to think of the film plane as lying at the eye point (Position)
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Focal Length





Some camera models take a Focal length
Focal Length is a measure of ideal focusing range; approximates behavior of
real camera lens
Objects at distance of Focal length from camera are rendered in focus; objects
closer or farther away than Focal length get blurred
Focal length used in conjunction with clipping planes
Only objects within view volume are rendered, whether blurred or not. Objects
outside of view volume still get discarded
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Limitations of this Camera Model
 Can create the following view volumes:
 perspective: positive view angle
 parallel: zero view angle
 Cannot create oblique view volume
 Non-oblique vs. oblique view volumes:
Non-oblique view volume:
Look vector perpendicular
to film plane
Oblique view volume:
Look vector at an angle
to film plane
 For example, view cameras with bellows are used to take pictures of
(tall) buildings.
 Film plane is parallel to the façade, while camera points up
 This is oblique view volume, with façade undistorted
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
References
 Carlbom, Ingrid and Paciorek, Joseph, “Planar Geometric Projections
and Viewing Transformations,” Computing Surveys, Vol. 10, No. 4
December 1978
 Kemp, Martin, The Science of Art, Yale University Press, 1992
 Mitchell, William J., The Reconfigured Eye, MIT Press, 1992
 Foley, van Dam, et. al., Computer Graphics: Principles and Practice,
Addison-Wesley, 1995
 Wernecke, Josie, The Inventor Mentor, Addison-Wesley, 1994
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Projection in Computer Graphics
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Look and Up Vectors
 More concrete way to say the same thing as orientation
 soon you’ll learn how to express orientation in terms of Look and Up vectors
 Look Vector
 the direction the camera is pointing
 three degrees of freedom; can be any vector in 3-space
 Up Vector
 determines how the camera is rotated around the Look vector
 for example, whether you’re holding the camera horizontally or vertically (or
in between)
 projection of Up vector must be in the plane perpendicular to the look vector
(this allows Up vector to be specified at an arbitrary angle to its Look vector)
projection of Up
vector
Up vector
Look vector
Position
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Clipping:
Parametric Clipping, Review
 D = P1 – P0 = (x1 – x0, y1 – y0)
 Leave PEi as an arbitrary point on the clip edge; it’s a free
variable and drops out
Calculations for Parametric Line Clipping Algorithm
Clip Edgei
Normal Ni
PEi
P0-PEi
left: x = xmin
(-1,0)
(xmin, y)
(x0- xmin,y0-y)
right: x = xmax
(1,0)
(xmax,y)
(x0- xmax,y0-y)
bottom: y = ymin
(0,-1)
(x, ymin)
(x0-x,y0- ymin)
top: y = ymax
(0,1)
(x, ymax)
(x0-x,y0- ymax)
N  (P  P )
i
0 Ei
N D
i
 (x  x
)
0 min
(x  x )
1 0
t
 (x  x
)
0 max
(x  x )
1 0
(y  y
)
0
min
(y  y )
1 0
(y  y
)
0
max
(y  y )
1 0
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Clipping:
Front and Back Clipping Planes [1]
 Volume of space between Front and Back clipping planes defines what
camera can see
 Position of planes defined by distance along Look vector
 Objects appearing outside of view volume don’t get drawn
 Objects intersecting view volume get clipped
Front clipping
plane
Back clipping
plane
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Clipping:
Front and Back Clipping Planes [2]
 Reasons for Front (near) clipping plane:
 Don’t want to draw things too close to the camera
 would block view of rest of scene
 objects would be prone to distortion
 Don’t want to draw things behind camera
 wouldn’t expect to see things behind the camera
 in the case of perspective camera, if we decided to draw things behind camera, they
would appear upside-down and inside-out because of perspective transformation
 Reasons for Back (far) clipping plane:
 Don’t want to draw objects too far away from camera
 distant objects may appear too small to be visually significant, but still take long time
to render
 by discarding them we lose a small amount of detail but reclaim a lot of rendering
time
 alternately, scene may be filled with many significant objects
 for visual clarity, we may wish to declutter scene by rendering those nearest camera
and discarding rest
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Clipping:
Front and Back Clipping Planes [3]


Have you ever played a video game and all of the sudden some object pops up in the
background (e.g. a tree in a racing game)? That’s the object coming inside the far clip
plane.
The old hack to keep you from noticing the pop-up is to add fog in the distance. A classic
example of this is from Turok: Dinosaur Hunter
Then (1997)
Now (2008)



Now all you notice is fog and how little you can actually see. This practically defeats the
purpose of an outdoor environment! And you can still see pop-up from time to time.
Thanks to fast hardware and level of detail algorithms, we can push the far plane back now
and fog is much less prevalent
Putting the near clip plane as far away as possible helps Z precision. Sometimes in a game
you can position the camera in the right spot so that the front of an object gets clipped
letting you see inside of it.
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
View Volume Specification
 From Position, Look vector, Up vector, Aspect ratio, Height
angle, Clipping planes, and (optionally) Focal length together
specify a truncated view volume
 Truncated view volume is a specification of bounded space
that camera can “see”
 2D view of 3D scene can be computed from truncated view
volume and projected onto film plane
 Truncated view volumes come in two flavors: parallel and
perspective
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
for
Orthographic Parallel
Projection
 Limiting view volume useful for eliminating extraneous objects
 Orthographic parallel projection has width and height view angles of zero
Width
Far distance
Look vector
Height
Near distance
Up vector
Position
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Truncated View Volume (Frustum)
for
Perspective Projection
 Removes objects too far from Position
 Otherwise would merge into “blobs”
 Removes objects too close to Position
 Would be excessively distorted
Width angle =
Height angle • Aspect
ratio
Up vector
Look vector
Height angle
Position
Near distance
Far distance
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Stage One:
Specifying a View Volume
 Reduce degrees of freedom
 Five steps to specifying view volume
 1. Position the camera
 and therefore its view/film plane
 2. Point it at what you want to see
 with camera in desired orientation
 3. Define the field of view
 for a perspective view volume, aspect ratio of film and angle of view:
somewhere between wide angle, normal, and zoom
 for a parallel view volume, width and height)
 4. Choose perspective or parallel projection
 5. Determine focal distance
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Specifying a View Volume

Placement of view volume (visible part of world) specified by camera’s position and
orientation
 Position (a point)
 Look and Up vectors

Shape of view volume specified by
 horizontal and vertical view angles
 front and back clipping planes



Perspective projection: projectors intersect at Position
Parallel projection: projectors parallel to Look vector, but never intersect (or
intersect at infinity)
Coordinate Systems
 world coordinates – standard right-handed xyz 3-space
 viewing reference coordinates – camera-space right handed coordinate system (u, v, n);
origin at Position and axes rotated by orientation; used for transforming arbitrary view into
canonical view
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Arbitrary View Volume too
Complex
 We have now specified an arbitrary view using our viewing parameters
 Problem: map arbitrary view specification to 2D picture of scene. This is
hard, both for clipping and for projection
 Solution: reduce to a simpler problem and solve
– Need: View specification from which it is easy to
take pictures
– Canonical view: from the origin, looking down
negative z-axis
– think of the scene as lying behind window and
we’re looking through the window
v
up
u
n
– parallel projection
– sits at origin: Position = (0, 0, 0)
– looks along negative z-axis: Look vector = (0, 0, –1)
– oriented upright: Up vector = (0, 1, 0)
– film plane extending from –1 to 1 in x and y
 Note: Look vector along negative, not positive, z-axis is arbitrary but
makes math easier
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Normalizing to
Canonical View Volume
 Our goal is to transform our arbitrary view and the world to the
canonical view volume, maintaining the relationship between view
volume and world, then take picture
 for parallel view volume, transformation is affine: made up of translations,
rotations, and scales
 in the case of a perspective view volume, it also contains a non-affine†
perspective transformation that frustum into a parallel view volume, a
cuboid
 the composite transformation that will transform the arbitrary view volume
to the canonical view volume, named the normalizing transformation, is still
a 4x4 homogeneous coordinate matrix that typically has an inverse
 easy to clip against this canonical view volume; clipping planes are axisaligned!
 projection using the canonical view volume is even easier: just omit the zcoordinate
 for oblique parallel projection, a shearing transform is part of the
composite transform, to “de-oblique” the view volume
† Affine transformations preserve parallelism but not lengths and angles. The perspective transformation is a
type of non-affine transformation known as a projective transformation, which does not preserve parallelism
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Viewing Transformation
 Normalizing Transformation
 Problem of taking a picture has now been reduced to problem of
finding correct normalizing transformation
 It is a bit tricky to find the rotation component of the normalizing
transformation.
 However, it is easier to find the inverse of this rotational component
(trust us)
 So we’ll digress for a moment and focus our attention on the inverse
of the normalizing transformation, which is called the viewing
transformation.
 The viewing transformation turns the canonical view into the arbitrary
view, or (x, y, z) to (u, v, n)
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Building Viewing Transformation
from View Specification
 We know the view specification: Position, Look vector, and Up vector
 We need to derive an affine transformation from these parameters
that will translate and rotate the canonical view into our arbitrary view
 the scaling of the film (i.e. the cross-section of the view volume) to make a
square cross-section will happen at a later stage, as will clipping
 Translation is easy to find: we want to translate the origin to the point
Position; therefore, the translation matrix is
1
0
T ( Position )  
0

0
0 0 Posx 
1 0 Pos y 
0 1 Posz 

0 0
1 
 Rotation is harder: how do we generate a rotation matrix from the
viewing specifications that will turn x, y, z, into u, v, n?
 a digression on rotation will help answer this
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Rotation [1]
3 x 3 rotation matrices
 We learned about 3 x 3 matrices that “rotate” the world (we’re leaving out the
homogeneous coordinate for simplicity)
 When they do, the three unit vectors that used to point along the x, y, and z
axes are moved to new positions
 Because it is a rigid-body rotation
 the new vectors are still unit vectors
 the new vectors are still perpendicular to each other
 the new vectors still satisfy the “right hand rule”
 Any matrix transformation that has these three properties is a rotation about
some axis by some amount!
 Let’s call the three x-axis, y-axis, and z-axis-aligned unit vectors e1, e2, e3
 Writing out:
1 
e1  0 
0 
0 
e2  1 
0 
0 
e3  0 
1 
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Rotation [2]
 Let’s call our rotation matrix M and suppose that it has columns v1, v2, and v3:
M  v1 v2
v3 
 When we multiply M by e1, what do we get?
Me1  v1 v2
v3 
1 
0   v
  1
0 
v3 
0 
1   v
  2
0 
v3 
0 
0   v
  3
1 
 Similarly for e2 and e3:
Me2  v1 v2
Me3  v1 v2
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Rotation [3]
 Thus, for any matrix M, we know that Me1 is the first column of M
 If M is a rotation matrix, we know that Me1 (i.e., where e1 got rotated
to) must be a unit-length vector (because rotations preserve length)
 Since Me1 = v1, the first column of any rotation matrix M must be a
unit vector
 Also, the vectors e1 and e2 are perpendicular…
 So if M is a rotation matrix, the vectors Me1 and Me2 are
perpendicular… (if you start with perpendicular vectors and rotate
them, they’re still perpendicular)
 But these are the first and second columns of M … Ditto for the other
two pairs
 As we noted in the slide on rotation matrices, for a rotation matrix
with columns vi
 columns must be unit vectors: ||vi|| = 1
 columns are perpendicular: vi • vj = 0 (i  j)
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Rotation [4]
 Therefore (for rotation matrices)
 v1  v1 v1  v2
v  v v  v
 2 1 2 2
v3  v1 v3  v2
v1  v3  1 0 0 
v2  v3   0 1 0 
v3  v3  0 0 1 
 We can write this matrix of vi•vj dot products as
MTM  I
where MT is a matrix whose rows are v1, v2, and v3
 Also, for matrices in general, M-1M = I, (actually, M-1 exists only for
“well-behaved” matrices)
 Therefore, for rotation matrices only we have just shown that M-1 is
simply MT
 MT is trivial to compute, M-1 takes considerable work: big win!
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Rotation [5]
Summary
 If M is a rotation matrix, then its columns are pairwise perpendicular
and have unit length
 Inversely, if the columns of a matrix are pairwise perpendicular and
have unit length and satisfy the right-hand rule, then the matrix is a
rotation
 For such a matrix,
1 0 0 
M T M  0 1 0 
0 0 1 
Adapted from slides for Brown University CS 123, Computer Graphics
© 2000 – 2007, A. van Dam. Used with permission.
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Summary
 History of Projections
 Normalizing and Viewing Transformations
 Perspective (to Parallel) Transformation
 Kinds of Projections
 Parallel
 Orthographic: top, front, side, other
 Axonometric: isometric, dimetric, trimetric
 Oblique: cavalier, cabinet
 Other
 Perspective: 1-point, 2-point, 3-point
 Viewing in OpenGL
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Terminology
 World Coordinates
 Screen Coordinates
 Normalizing Transformation
 Viewing Transformation
 Duality
 Perspective (to Parallel) Transformation
 Projections
 Parallel
 Orthographic: top, front, side, other
 Axonometric: isometric, dimetric, trimetric
 Oblique: cavalier, cabinet
 Other
 Perspective: 1-point, 2-point, 3-point
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University
Next: OpenGL Tutorial 2
 Four More Short OpenGL Tutorials from SIGGRAPH 2000
 Vicki Shreiner: Animation and Depth Buffering
 Double buffering
 Illumination: light positioning, light models, attenuation
 Material properties
 Animation basics in OpenGL
 Vicki Schreiner: Imaging and Raster Primitives
 Ed Angel: Texture Mapping
 Dave Shreiner: Advanced Topics
 Display lists and vertex arrays
 Accumulation buffer
 Fog
 Stencil buffering
 Fragment programs (to be concluded in Tutorial 3)
CIS 636/736: (Introduction to) Computer
Graphics
CG Basics 4 of 8: Viewing
Computing & Information Sciences
Kansas State University