![Page 1: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/1.jpg)
Introduction to Computer Graphics5. Viewing in 3D (A)
National Chiao Tung Univ, TaiwanBy: I-Chen Lin, Assistant Professor
Textbook: Hearn and Baker, Computer Graphics, 3rd Ed., Prentice HallRef: E.Angel, Interactive Computer Graphics, 4th Ed., Addison Wesley
![Page 2: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/2.jpg)
OutlineClassical views
Computer viewing
Projection matrices
![Page 3: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/3.jpg)
Classical ViewingViewing requires three basic elements
One or more objectsA viewer with a projection surfaceProjectors that go from the object(s) to the projection surface
Each object is assumed to constructed from flat principal faces
Buildings, polyhedra, manufactured objects
![Page 4: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/4.jpg)
Planar Geometric ProjectionsStandard projections project onto a plane.
Projectors are lines that eitherconverge at a center of projectionare parallel
Such projections preserve linesbut not necessarily angles
When do we need non-planar projections?
![Page 5: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/5.jpg)
Classical Projections
![Page 6: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/6.jpg)
Perspective vs ParallelClassical viewing developed different techniques for drawing each type of projection
Mathematically parallel viewing is the limit of perspective viewing
Computer graphics treats all projections the same and implements them with a single pipeline
![Page 7: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/7.jpg)
Taxonomy of Planar Geometric Projections
parallel perspective
axonometricmultivieworthographic
oblique2 point1 point 3 point
planar geometric projections
isometric dimetric trimetric
![Page 8: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/8.jpg)
Perspective Projection
![Page 9: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/9.jpg)
Parallel Projection
![Page 10: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/10.jpg)
Orthographic ProjectionProjectors are orthogonal to projection surface
![Page 11: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/11.jpg)
Multiview Orthographic ProjectionProjection plane parallel to principal facesUsually form front, top, side views
isometric (not multivieworthographic view) front
side
in CAD and architecture, we often display three multiviews plus isometric
top
![Page 12: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/12.jpg)
Advantages and DisadvantagesPreserves both distances and angles
Shapes preservedCan be used for measurements
Building plansManuals
Cannot see what object really looks like because many surfaces hidden from view
Often we add the isometric
![Page 13: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/13.jpg)
Axonometric ProjectionsAllow projection plane to move relative to object
classify by how many angles ofa corner of a projected cube are the same
none: trimetrictwo: dimetricthree: isometric
θ 1θ 3θ 2
![Page 14: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/14.jpg)
Types of Axonometric Projections
![Page 15: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/15.jpg)
Advantages and DisadvantagesLines are scaled (foreshortened) but can find scaling factors
Lines preserved but angles are notProjection of a circle in a plane not parallel to the projection plane is an ellipse
Does not look real because far objects are scaled the same as near objects
Used in CAD applications
![Page 16: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/16.jpg)
Oblique ProjectionArbitrary relationship between projectors and projection plane
![Page 17: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/17.jpg)
Perspective ProjectionProjectors coverage at center of projection
![Page 18: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/18.jpg)
Vanishing PointsParallel lines (not parallel to the projection plan):
converge at a single point in the projection (the vanishing point)
Drawing simple perspectives by hand uses these vanishing point(s)
vanishing point
![Page 19: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/19.jpg)
Three-Point PerspectiveNo principal face parallel to projection planeThree vanishing points for cube
![Page 20: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/20.jpg)
Two-Point PerspectiveOn principal direction parallel to projection planeTwo vanishing points for cube
![Page 21: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/21.jpg)
One-Point PerspectiveOne principal face parallel to projection planeOne vanishing point for cube
![Page 22: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/22.jpg)
Advantages and DisadvantagesDiminution:
Objects further from viewer are projected smaller (Looks realistic)
Nonuniform foreshortening:Equal distances along a line are not projected into equal distances
Angles preserved only in planes parallel to the projection plane
More difficult to construct by hand than parallel projections
![Page 23: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/23.jpg)
Computer Viewing
![Page 24: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/24.jpg)
Pipeline View
ModelingTransformation
ModelingTransformation
ViewingTransformation
ViewingTransformation
ProjectionTransformation
ProjectionTransformation
Normalizationand
clipping
Normalizationand
clipping
ViewportTransformation
ViewportTransformation
MC WC VC
PC NC DC
Let’s skip the clipping temporarily !
![Page 25: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/25.jpg)
Computer ViewingThree aspects of the viewing process implemented in the pipeline:
Positioning the cameraSetting the model-view matrix
Selecting a lensSetting the projection matrix
ClippingSetting the view volume
![Page 26: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/26.jpg)
The OpenGL CameraIn OpenGL, initially the object and camera frames are the same
Default model-view matrix is an identity
The camera is located at origin and points in the negative z direction
OpenGL also specifies a default view volume that is a cube with sides of length 2 centered at the origin
Default projection matrix is an identity
![Page 27: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/27.jpg)
Moving the Camera FrameIf we want to visualize object with both positive and negative z values we can either
Move the camera in the positive z directionTranslate the camera frame
Move the objects in the negative z directionTranslate the world frame
Both of these views are equivalent and are determined by the model-view matrix
Want a translation (glTranslatef(0.0,0.0,-d);)d > 0
![Page 28: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/28.jpg)
Moving Camera back from Origin
default frames
frames after translation by –dd > 0
![Page 29: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/29.jpg)
Moving the CameraWe can move the camera to any desired position by a sequence of rotations and translations
Example: side viewRotate the cameraMove it away from originModel-view matrix C = TR
![Page 30: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/30.jpg)
gluLookAtglLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz)
![Page 31: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/31.jpg)
Projections and NormalizationThe default projection in the eye (camera) frame is orthogonal For points within the default view volume
xp = xyp = yzp = 0
![Page 32: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/32.jpg)
Homogeneous Coordinate Representation
default orthographic projectionxp = xyp = yzp = 0wp = 1
pp = Mp
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
1000000000100001
M =
In practice, we can let M = I and setthe z term to zero later
![Page 33: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/33.jpg)
Simple PerspectiveCenter of projection at the originProjection plane z = d, d < 0
![Page 34: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/34.jpg)
Perspective EquationsTop view Side view
dzx/
dzx/ dz
y/
xp = yp = zp = d
![Page 35: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/35.jpg)
Homogeneous Coordinate Form
M =
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
0/100010000100001
d
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
dzzyx
/
consider q = Mp where
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
1zyx
⇒ q = p =
![Page 36: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/36.jpg)
Perspective DivisionHowever w ≠ 1, so we must divide by w to return from homogeneous coordinatesThis perspective division yields
the desired perspective equations
dzx/ dz
y/
xp = yp = zp = d
![Page 37: Introduction to Computer Graphics - CAIG Labcaig.cs.nctu.edu.tw/course/CG07/Lectures/CG_5_ViewingA_S07.pdfIntroduction to Computer Graphics 5. Viewing in 3D (A) National Chiao Tung](https://reader033.vdocument.in/reader033/viewer/2022042708/5aa961b67f8b9a81188cb37b/html5/thumbnails/37.jpg)
Viewport TransformationFrom the working coordinate to the coordinate of display device.
(1,1)
(-1,-1)
(0,0)
(0,0)
(600,600)
By 2D scaling and translation
Next: clipping and normalization !