Classical Views • Computer Viewing • Perspective Normalization
Total Page:16
File Type:pdf, Size:1020Kb
Overview • Classical views • Computer viewing Viewing and perspectives • Perspective normalization Planar Geometric Classical Viewing Projections • Viewing requires three basic elements • Standard projections project onto a plane – One or more objects – A viewer with a projection surface • Projectors are lines that either – Projectors that go from the object(s) to the – converge at a center of projection projection surface – are parallel • Classical views are based on the relationship among these elements • Such projections preserve lines – The viewer picks up the object and orients it how – but not necessarily angles she would like to see it • Nonplanar projections are needed for • Each object is assumed to constructed from flat applications such as map construction principal faces – Buildings, polyhedra, manufactured objects Classical Projections Perspective vs Parallel • Computer graphics treats all projections the same and implements them with a single pipeline • Classical viewing developed different techniques for drawing each type of projection • Fundamental distinction is between parallel and perspective viewing even though mathematically parallel viewing is the limit of perspective viewing Taxonomy of Planar Perspective Projection Geometric Projections planar geometric projections parallel perspective 1 point2 point 3 point multiview axonometric oblique orthographic isometric dimetric trimetric Parallel Projection Orthographic Projection Projectors are orthogonal to projection surface Multiview Orthographic Advantages and Disadvantages Projection • Projection plane parallel to principal face • Preserves both distances and angles • Usually form front, top, side views – Shapes preserved isometric (not multiview – Can be used for measurements orthographic view) front • Building plans • Manuals in CAD and architecture, • Cannot see what object really looks like we often display three because many surfaces hidden from view multiviews plus isometric side – Often we add the isometric top Types of Axonometric Axonometric Projections Projections Allow projection plane to move relative to object classify by how many angles of a corner of a projected cube are the same θ 1 none: trimetric θ θ 2 3 two: dimetric three: isometric Advantages and Disadvantages Example, isometric/dimetric • Lines 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 projection plane is an ellipse • Can see three principal faces of a box-like object • Some optical illusions possible – Parallel lines appear to diverge • Does not look real because far objects are scaled the same as near objects • Used in CAD applications, games Oblique Projection Advantages and Disadvantages Arbitrary relationship between projectors and • Can pick the angles to emphasize a particular projection plane face – Architecture: plan oblique, elevation oblique • Angles in faces parallel to projection plane are preserved while we can still see “around” side • In physical world, cannot create with simple camera; possible with bellows camera or special lens (architectural) Perspective Projection Vanishing Points Projectors coverge at center of projection • Parallel lines (not parallel to the projection plan) 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 One-Point Perspective Two-Point Perspective • One principal face parallel to projection plane • One principal direction parallel to projection • One vanishing point for cube plane • Two vanishing points for cube Three-Point Perspective Advantages and Disadvantages • No principal face parallel to projection plane • Objects further from viewer are projected smaller • Three vanishing points for cube than the same sized objects closer to the viewer (diminution ) – Looks realistic • Equal distances along a line are not projected into equal distances ( nonuniform foreshortening ) • Angles preserved only in planes parallel to the projection plane • More difficult to construct by hand than parallel projections (but not more difficult by computer) Computer Viewing The OpenGL Camera • There are three aspects of the viewing • In OpenGL, initially the object and process, all of which are implemented in camera frames are the same the pipeline, – Default model-view matrix is an identity – Positioning the camera • The camera is located at origin and • Setting the model-view matrix points in the negative z direction – Selecting a lens • OpenGL also specifies a default view • Setting the projection matrix volume that is a cube with sides of length – Clipping 2 centered at the origin • Setting the view volume – Default projection matrix is an identity Moving the Camera Default Projection Frame Default projection is orthogonal • If we want to visualize object with both positive and negative z values we can either clipped out – Move the camera in the positive z direction 2 • Translate the camera frame – Move the objects in the negative z direction • Translate the world frame z=0 • 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 Moving Camera back from Moving the Camera Origin frames after translation by –d • We can move the camera to any desired d > 0 position by a sequence of rotations and default frames translations • Example: side view – Rotate the camera – Move it away from origin – Model-view matrix C = TR OpenGL code The LookAt Function • Remember that last transformation • The GLU library contains the function specified is first to be applied gluLookAt to form the required modelview matrix through a simple interface • Note the need for setting an up direction glMatrixMode(GL_MODELVIEW) glLoadIdentity(); • Still need to initialize glTranslatef(0.0, 0.0, -d); glRotatef(90.0, 0.0, 1.0, 0.0); – Can concatenate with modeling transformations • Example: isometric view of cube aligned with axes glMatrixMode(GL_MODELVIEW): glLoadIdentity(); gluLookAt(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0., 1.0. 0.0); gluLookAt Other Viewing APIs glLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz) • The LookAt function is only one possible API for positioning the camera • Others include – View reference point, view plane normal, view up (PHIGS, GKS-3D) – Yaw, pitch, roll – Elevation, azimuth, twist – Direction angles Projections and Homogeneous Coordinate Normalization Representation • The default projection in the eye (camera) frame is default orthographic projection orthogonal xp = x p = Mp • For points within the default view volume p yp = y xp = x zp = 0 1 0 0 0 y = y w = 1 p p 0 1 0 0 zp = 0 M = 0 0 0 0 • Most graphics systems use view normalization – All other views are converted to the default view by 0 0 0 1 transformations that determine the projection matrix – Allows use of the same pipeline for all views In practice, we can let M = I and set the z term to zero later Simple Perspective Perspective Equations • Center of projection at the origin Consider top and side views • Projection plane z = d, d < 0 x z / d x y xp = yp = zp = d z / d z / d Homogeneous Coordinate Perspective Division Form 1 0 0 0 • However w ≠ 1, so we must divide by w to consider q = Mp where M = 0 1 0 0 return from homogeneous coordinates 0 0 1 0 • This perspective division yields 0 0 /1 d 0 x y xp = yp = zp = d x x z / d z / d y y the desired perspective equations q = ⇒⇒⇒ p = z z • We will consider the corresponding clipping volume with the OpenGL 1 z / d functions OpenGL Orthogonal Viewing OpenGL Perspective glOrtho(left,right,bottom,top,near,far) glFrustum(left,right,bottom,top,near,far) near and far measured from camera Using Field of View Normalization • With glFrustum it is often difficult to get the • Rather than derive a different projection desired view matrix for each type of projection, • gluPerpective(fovy, aspect, near, – convert all projections to orthogonal far) often provides a better interface projections with the default view volume front plane • Use standard transformations in the pipeline aspect = w/h • Makes for efficient clipping Pipeline View Notes • Stay in four-dimensional homogeneous coordinates through both the modelview modelview projection perspective and projection transformations transformation transformation division – Both these transformations are nonsingular 4D → 3D – Default to identity matrices (orthogonal view) nonsingular • Normalization lets us clip against simple cube regardless of type of projection clipping projection • Delay final projection until end → – Important for hidden-surface removal to against default cube 3D 2D retain depth information as long as possible Orthogonal Normalization Orthogonal Matrix glOrtho(left,right,bottom,top,near,far) • Two steps – Move center to origin normalization ⇒ find transformation to convert specified clipping volume to default T(-(left+right)/2, -(bottom+top)/2,(near+far)/2)) – Scale to have sides of length 2 S(2/(left-right),2/(top-bottom),2/(near-far)) 2 right − left 0 0 − − − right left right left 2 top + bottom 0 0 − P = ST = top − bottom top − bottom 2 far + near 0 0 near − far far − near 0 0 0 1 Final Projection Oblique Projections • Set z =0 • The OpenGL projection functions cannot produce general parallel projections such as • Equivalent to the homogeneous coordinate transformation 1 0 0 0 0 1 0 0 M = orth 0 0 0 0 0 0 0 1 • However if we look at