Computer Graphics 7: Viewing in 3-D
In today s lecture we are going to have a look at: Transformations in 3-D How do transformations in 3-D work? Contents 3-D homogeneous coordinates and matrix based transformations Projections History Geometrical Constructions Types of Projection Projection in Computer Graphics
3-D Coordinate Spaces Remember what we mean by a 3-D coordinate space y axis y P z axis z x x axis Right-Hand Reference System
Translations In 3-D To translate a point in three dimensions by dx, dy and dz simply calculate the new points as follows: x = x + dx y = y + dy z = z + dz (x, y, z) (x, y, z ) Translated Position
Scaling In 3-D To sale a point in three dimensions by sx, sy and sz simply calculate the new points as follows: x = sx*x y = sy*y z = sz*z (x, y, z) (x, y, z ) Scaled Position
Rotations In 3-D (cont ) The equations for the three kinds of rotations in 3-D are as follows: x = x cosθ - y sinθ y = x sinθ + y cosθ z = z x = x y = y cosθ - z sinθ z = y sinθ + z cosθ x = z sinθ + x cosθ y = y z = z cosθ - x sinθ
Homogeneous Coordinates In 3-D Similar to the 2-D situation we can use homogeneous coordinates for 3-D transformations - 4 coordinate y axis column vector All transformations can then be represented as matrices P(x, y, z) = x y z 1 z axis z y P x x axis
3D Transformation Matrices 1 1 1 1 dz dy dx 1 z y x s s s Translation by dx, dy, dz Scaling by sx, sy, sz 1 1 1 cos sin 1 sin cos θ θ θ θ 1 cos sin sin cos 1 θ θ θ θ Rotate About X-Axis 1 1 cos sin sin cos θ θ θ θ Rotate About Y-Axis Rotate About Z-Axis
Remember The Big Idea
1 of 23 Viewing a 3D world Display plane World coordinate frame Camera position (or eye point, view point, viewing position)
(Variation of Fig 7-11, pg. 299) 3D Viewing Pipeline Modeling coordinates Construct World Coordinate Scene Using Model- Coordinate Transformations Convert World Coordinates to Viewing Coordinates Transform Viewing Coordinates to Normalized Coordinates Modeling coordinates World coordinates Viewing coordinates 2D pipeline 3D pipeline Construct World Coordinate Scene Using Model- Coordinate Transformations World coordinates Convert World Coordinates to Viewing Coordinates Projection Transformation Transform Viewing Coordinates to Normalized Coordinates Viewing coordinates Projection coordinates Normalized coordinates Normalized coordinates Map Normalized Coordinates to Device Coordinates Map Normalized Coordinates to Device Coordinates Device coordinates Device coordinates
What Are Projections? Our 3-D scenes are all specified in 3-D world coordinates To display these we need to generate a 2-D image - project objects onto a picture plane Picture Plane Objects in World Space So how do we figure out these projections?
Converting From 3-D To 2-D Projection is just one part of the process of converting from 3-D world coordinates to a 2-D image 3-D world coordinate output primitives Clip against view volume Project onto projection plane Transform to 2-D device coordinates 2-D device coordinates
Projections Need to project from 3D to 2D 2 kinds of projection Parallel projection Perspective projection
Parallel Projection
Perspective Projection
Types Of Projections There are two broad classes of projection: Parallel: Typically used for architectural and engineering drawings Perspective: Realistic looking and used in computer graphics Parallel Projection Perspective Projection
Types Of Projections (cont ) For anyone who did engineering or technical drawing
Parallel Projections Some examples of parallel projections Orthographic Projection Isometric Projection
Perspective Projections There are a number of different kinds of perspective views The most common are one-point and two point perspectives One Point Perspective Projection Two-Point Perspective Projection
Elements Of A Perspective Projection Virtual Camera
Projection of up vector Up vector Position The Up And Look Vectors Look vector camera is rotated The look vector indicates the direction in which the camera is pointing The up vector determines how the For example, is the camera held vertically or horizontally
In today s lecture we looked at: Transformations in 3-D Very similar to those in 2-D Projections Summary 3-D scenes must be projected onto a 2-D image plane Lots of ways to do this Parallel projections Perspective projections The virtual camera
Perspective Projections Remember the whole point of perspective projections
Setting Up A Perspective Projection We need one more thing to specify a perspective projections using the filed of view angle (cont ) The aspect ratio gives the ratio between the width sand height of the view plane
Contents Now lecture we are going to have a look at some perspective view demos and investigate how clipping works in 3-D Nate Robins OpenGL tutorials The clipping volume The zone labelling scheme 3-D clipping Point clipping Line clipping Polygon clipping
3-D Clipping Just like the case in two dimensions, clipping removes objects that will not be visible from the scene The point of this is to remove computational effort 3-D clipping is achieved in two basic steps Discard objects that can t be viewed i.e. objects that are behind the camera, outside the field of view, or too far away Clip objects that intersect with any clipping plane
Discard Objects Discarding objects that cannot possibly be seen involves comparing an objects bounding box/sphere against the dimensions of the view volume Can be done before or after projection
Clipping Objects Objects that are partially within the viewing volume need to be clipped just like the 2D case
Normalisation The transformed volume is then normalised around position (,, ) and the z axis is reversed
Dividing Up The World Similar to the case in two dimensions, we divide the world into regions This time we use a 6-bit region code to give us 27 different region codes The bits in these regions codes are as follows: bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 Far Near Top Bottom Right Left
Region Codes
3D Line Clipping Example (cont ) When then simply continue as per the two dimensional line clipping algorithm
3D Polygon Clipping However the most common case in 3D clipping is that we are clipping graphics objects made up of polygons
3D Polygon Clipping (cont ) In this case we first try to eliminate the entire object using its bounding volume Next we perform clipping on the individual polygons using the Sutherland-Hodgman algorithm we studied previously
Summary In today s lecture we examined how clipping is achieved in 3-D