co graphics
Transcript of co graphics
-
7/28/2019 co graphics
1/44
Chapter 6
Computer Graphics and Visualization
SSE, Mukka
1
-
7/28/2019 co graphics
2/44
2
Classical Viewing
Introduce the classical views
Compare and contrast image formation bycomputer with how images have been formed byarchitects, artists, and engineers
Learn the benefits and drawbacks of each type ofview
-
7/28/2019 co graphics
3/44
3
Classical Viewing
Viewing requires three basic elements One or more objects
A viewer with a projection surface
Projectors that go from the object(s) to the projectionsurface
Classical views are based on the relationship amongthese elements The viewer picks up the object and orients it how she
would like to see it
Each object is assumed to constructed from flatprincipal faces Buildings, polyhedra, manufactured objects
-
7/28/2019 co graphics
4/44
4
Planar GeometricProjections
Standard projections project onto a plane
Projectors are lines that either
converge at a center of projection
are parallel
Such projections preserve lines
but not necessarily angles
Nonplanar projections are needed for applicationssuch as map construction
-
7/28/2019 co graphics
5/44
5
Classical Projections
-
7/28/2019 co graphics
6/44
6
Perspective vs Parallel
Computer graphics treats all projections the sameand implements them with a single pipeline
Classical viewing developed different techniques fordrawing each type of projection
Fundamental distinction is between parallel andperspective viewing even though mathematicallyparallel viewing is the limit of perspective viewing
-
7/28/2019 co graphics
7/44
7
Taxonomy of PlanarGeometric Projections
parallel perspective
axonometricmultiview
orthographic oblique
isometric dimetric trimetric
2 point1 point 3 point
planar geometric projections
-
7/28/2019 co graphics
8/44
8
-
7/28/2019 co graphics
9/44
9
PerspectiveProjection
-
7/28/2019 co graphics
10/44
10
Parallel Projection
-
7/28/2019 co graphics
11/44
11
Orthographic ProjectionProjectors are orthogonal to projection surface
-
7/28/2019 co graphics
12/44
12
Multiview Orthographic
ProjectionProjection plane parallel to principal face
Usually form front, top, side views
isometric (not multiview
orthographic view)front
sidetop
in CAD and architecture,
we often display threemultiviews plus isometric
-
7/28/2019 co graphics
13/44
13
Advantages and
Disadvantages Preserves both distances and angles
Shapes preserved
Can be used for measurements
Building plans
Manuals
Cannot see what object really looks like becausemany surfaces hidden from view
Often we add the isometric
-
7/28/2019 co graphics
14/44
14
Axonometric ProjectionsAllow projection plane to move relative to object
classify by how many angles of
a corner of a projected cube are
the same
none: trimetric
two: dimetric
three: isometric
q 1
q 3q 2
-
7/28/2019 co graphics
15/44
Axonometric Projections
15
The distinguishing feature of axonometric projection is the inclined
position of the object with respect to the plane of projection.
The axonometric axis is the intersection of the three edges of the cube
at the corner (O).
Axonometric projections are classified as isometric projection (a),
dimetric projection (b), and trimetric projection (c).
-
7/28/2019 co graphics
16/44
16
Types of AxonometricProjections
-
7/28/2019 co graphics
17/44
17
Advantages and
DisadvantagesLines are scaled (foreshortened) but can find scaling
factors
Lines preserved but angles are not Projection of a circle in a plane not parallel to the projectionplane is an ellipse
Can see three principal faces of a box-like objectSome optical illusions possible
Parallel lines appear to divergeDoes not look real because far objects are scaled
the same as near objectsUsed in CAD applications
-
7/28/2019 co graphics
18/44
18
Oblique Projection
Arbitrary relationship between projectors andprojection plane
-
7/28/2019 co graphics
19/44
19
Advantages and
DisadvantagesCan pick the angles to emphasize a particular
face
Architecture: plan oblique, elevation obliqueAngles in faces parallel to projection plane are
preserved while we can still see around side
In physical world, cannot create with simplecamera; possible with bellows camera orspecial lens (architectural)
-
7/28/2019 co graphics
20/44
20
Perspective Projection
Projectors coverge at center of projection
-
7/28/2019 co graphics
21/44
21
Vanishing Points
Parallel lines (not parallel to the projectionplan) on the object converge at a single point in
the projection (the vanishing point)Drawing simple perspectives by hand uses
these vanishing point(s)
vanishing point
-
7/28/2019 co graphics
22/44
22
Three-Point Perspective
No principal face parallel to projection plane
Three vanishing points for cube
-
7/28/2019 co graphics
23/44
23
Two-Point Perspective
On principal direction parallel to projectionplane
Two vanishing points for cube
-
7/28/2019 co graphics
24/44
24
One-Point Perspective
One principal face parallel to projection plane
One vanishing point for cube
-
7/28/2019 co graphics
25/44
25
Advantages and
DisadvantagesObjects further from viewer are projected smaller
than the same sized objects closer to the viewer
(diminution) Looks realistic
Equal distances along a line are not projected intoequal distances (nonuniform foreshortening)
Angles preserved only in planes parallel to theprojection plane
More difficult to construct by hand than parallelprojections (but not more difficult by computer)
-
7/28/2019 co graphics
26/44
26
Computer Viewing
There are three aspects of the viewing process, all ofwhich are implemented in the pipeline,
Positioning the camera Setting the model-view matrix
Selecting a lens
Setting the projection matrix
Clipping
Setting the view volume
-
7/28/2019 co graphics
27/44
27
The OpenGL Camera In 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 directionOpenGL 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
-
7/28/2019 co graphics
28/44
28
DefaultProjection
Default projection is orthogonalclipped out
z=0
2
-
7/28/2019 co graphics
29/44
29
Moving the Camera Frame
If we want to visualize object with both positiveand negative z values we can either Move the camera in the positive z direction
Translate the camera frame
Move the objects in the negative z direction
Translate the world frame
Both of these views are equivalent and are determined
by the model-view matrixWant a translation (glTranslatef(0.0,0.0,-d);)
d > 0
-
7/28/2019 co graphics
30/44
30
Moving Camera back from
Origin
default frames
frames after translation by d
d > 0
-
7/28/2019 co graphics
31/44
31
Moving the Camera
We can move the camera to any desired position by asequence of rotations and translations
Example: side view Rotate the camera
Move it away from origin
Model-view matrix C = TR
-
7/28/2019 co graphics
32/44
32
OpenGL code
Remember that last transformation specified is firstto be applied
glMatrixMode(GL_MODELVIEW)glLoadIdentity();glTranslatef(0.0, 0.0, -d);glRotatef(90.0, 0.0, 1.0, 0.0);
-
7/28/2019 co graphics
33/44
33
The LookAt FunctionThe GLU library contains the function
gluLookAt to form the required modelviewmatrix through a simple interface
Note the need for setting an up directionStill need to initialize Can concatenate with modeling transformations
Example: isometric view of cube aligned with
axesglMatrixMode(GL_MODELVIEW):glLoadIdentity();gluLookAt(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0., 1.0. 0.0);
-
7/28/2019 co graphics
34/44
34
gluLookAtglLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz)
-
7/28/2019 co graphics
35/44
35
Other Viewing APIs
The LookAt function is only one possible API forpositioning the camera
Others include View reference point, view plane normal, view up
(PHIGS, GKS-3D)
Yaw, pitch, roll
Elevation, azimuth, twist Direction angles
P j i d
-
7/28/2019 co graphics
36/44
36
Projections andNormalization
The default projection in the eye (camera) frame isorthogonal
For points within the default view volume
Most graphics systems use view normalization
All other views are converted to the default view bytransformations that determine the projection matrix
Allows use of the same pipeline for all views
xp = xyp = y
zp = 0
H C di
-
7/28/2019 co graphics
37/44
37
Homogeneous CoordinateRepresentation
xp = x
yp = y
zp
= 0
wp = 1
pp = Mp
M =
1000
0000
0010
0001
In practice, we can let M = I and set
the zterm to zero later
default orthographic projection
-
7/28/2019 co graphics
38/44
38
Simple Perspective
Center of projection at the origin
Projection plane z= d, d< 0
-
7/28/2019 co graphics
39/44
39
Perspective Equations
Consider top and side views
xp =
dz
x
/
dz
x
/
yp =
dz
y
/
zp = d
-
7/28/2019 co graphics
40/44
40
Homogeneous Coordinate Form
M =
0/100
0100
0010
0001
d
consider q = Mp where
1
zy
x
dz
z
y
x
/
q = p =
-
7/28/2019 co graphics
41/44
41
Perspective Division
However w 1, so we must divide by w to return fromhomogeneous coordinates
Thisperspective division yields
the desired perspective equations
We will consider the corresponding clipping volumewith the OpenGL functions
xp =
dz
x
/
yp =
dz
y
/
zp = d
-
7/28/2019 co graphics
42/44
42
OpenGL Orthogonal Viewing
glOrtho(left,right,bottom,top,near,far)
near and far measured from camera
-
7/28/2019 co graphics
43/44
43
OpenGL Perspective
glFrustum(left,right,bottom,top,near,far)
-
7/28/2019 co graphics
44/44
44
Using Field of ViewWith glFrustumit is often difficult to get the desired
view
gluPerpective(fovy, aspect, near,far) often provides a better interface
aspect = w/h
front plane