0% found this document useful (0 votes)
14 views

Lecture 7 Three dimensional graphics

perfect notes
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Lecture 7 Three dimensional graphics

perfect notes
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

THREE DIMENSIONAL

GRAPHICS
CCS 2208 COMPUTER GRAPHICS
3D Modeling Transformations
• Methods for object modeling transformation in three
dimensions are extended from two dimensional methods
by including consideration for the z coordinate.
• Straightforward for translation and scale, rotation more
difficult
• Homogeneous coordinates: 4 components

• Transformation matrices: 4×4 elements


3D Point Homogenous Coordinate
• A 3D point P is represented in homogeneous coordinates
by a 4-dimensional Vector
• The main advantage: it is easier to compose translation
and rotation
• Everything is matrix multiplication
 x
 x  y
 y P  
   z
 z   
 1
3D Transformation
• In homogeneous coordinates, 3D transformations
are represented by 4×4 matrixes:

a b c tx 
d e f ty 
 
g h i tz 
 
0 0 0 1
3D Translation
• P is translated to P' by:
 x   1 0 0 tx   x
 y   0 1 0 t y   y
     
 z   0 0 1 tz   z 
     
 1  0 0 0 1   1
P T P
3D Translation
Very similar to 2D. Using 4x4 matrices rather than 3x3.

y x  x  t x

y  y  t y

z z  t z
 x, y, z  x  1 0 0 tx   x 
 x, y , z   y  0  
1 0 ty   y
   
z x  z   0 0 1 tz   z 
     
 1  0 0 0 1   1
3D Rotation
 Rotations are specified by a rotation axis and an angle
 The easiest rotation axes are those that are parallel to
the coordinate axis.
 Positive rotation angles produce counterclockwise
rotations about a coordinate axis, if we are looking along
the positive half of the axis toward the coordinate origin.
Coordinate Axis Rotations
 Z-axis rotation: For z axis same as 2D rotation:
 x'  cos   sin  0 0  x 
P R z ( ) P  y '  sin  cos  0 0  y 
   
 z'  0 0 1 0  z 
     
 1  0 0 0 1  1 
Coordinate Axis Rotations
 X-axis rotation:
 x'  1 0 0 0  x 
P R x ( ) P  y '  0 cos   sin  0  y 
     
 z '   0 sin  cos  0  z 
     
 1  0 0 0 1  1 
Coordinate Axis Rotations
 Y-axis rotation:
 x'  cos  0 sin  0  x 
P R y ( ) P  y '  0 1 0 0  y 
  

 z '    sin  0 cos  0  z 
     
 1  0 0 0 1  1 
General 3D Rotation
1. Translate the object such that rotation axis passes
through the origin.
2. Rotate the object such that rotation axis coincides with
one of Cartesian axes.
3. Perform specified rotation about the Cartesian axis.
4. Apply inverse rotation to return rotation axis to original
direction.
5. Apply inverse translation to return rotation axis to
original position.
General 3D Rotation

with the rotation


axis projected
onto the Z axis
3D Scaling
y y
x  x S x

y  y S y

z   x S z
z x z x
Changes the size of the object and repositions the object
relative to the coordinate origin.
 x  S x 0 0 0  x 
 y  0 Sy 0 0   y 
P       S P
 z   0 0 Sz 0  z 
     
 1  0 0 0 1  1 
3D Rendering Pipeline
3D Geometric Primitives

Modeling
Modeling
Transformation
Transformation Transform into 3D world coordinate system

Lighting
Transform into 3D camera coordinate system
Lighting
Done with modeling transformation
Viewing
Viewing Illuminate according to lighting and reflectance
Transformation
Transformation Apply texture maps
Projection
Projection Transform into 2D screen coordinate system
Transformation
Transformation

Clipping
Clipping Clip primitives outside camera’s view

Scan
Scan
Conversion
Conversion Draw pixels (includes texturing, hidden surface, ...)

Image (this pipeline applies only for direct illumination)


Example: OpenGL

Modeling
Modeling
Transformation
Transformation glBegin(GL_POLYGON);
glVertex3f(0.0, 0.0, 0.0);
Viewing
Viewing
Transformation
Transformation glVertex3f(1.0, 0.0, 0.0);
glVertex3f(1.0, 1.0, 1.0);
Lighting
Lighting &
& glVertex3f(0.0, 1.0, 1.0);
Texturing
Texturing glEnd();
Projection
Projection
Transformation
Transformation
OpenGL executes steps
Clipping
Clipping
of 3D rendering pipeline
for each polygon
Scan
Scan Conversion
Conversion

Image
Camera Coordinates
• Canonical coordinate system
• Convention is right-handed (looking down -z axis)
• Convenient for projection, clipping, etc.

Camera up vector
y maps to Y axis

Camera right vector


Camera back vector
maps to X axis
maps to Z axis
(pointing out of screen) z x
Viewing Transformation
• Mapping from world to camera coordinates
• Eye position maps to origin
• Right vector maps to X axis
• Up vector maps to Y axis
back
• Back vector maps to Z axis up
right

y
View
plane
Camera
z

World
Viewing Transformations
p(x,y,z)
3D Object Coordinates
Modeling
Modeling


Transformation
Transformation
3D World Coordinates
Viewing
Viewing
Transformation
Transformation
3D Camera Coordinates Viewing Transformations
Projection
Projection
Transformation
Transformation
2D Screen Coordinates
Window-to-Viewport
Window-to-Viewport
Transformation
Transformation

2D Image Coordinates
p’(x’,y’)
Projection
• General definition: Transform points in n-space to m-space
(m<n)

• In computer graphics: Map 3D camera coordinates to 2D


screen coordinates

• In 3D, we map points from 3-space to the projection plane


(PP) (a.k.a., image plane) along projectors (a.k.a., viewing
rays) emanating from the center of projection (COP)

• There are two basic types of projections:


• Perspective – distance from COP to PP finite
• Parallel – distance from COP to PP infinite
Parallel vs Perspective Projection
• Parallel Projection
• Preserve size
• Good for determining relative size
• Perspective Projection
• Projection along rays, no two “rays” are parallel to each
other
• Closer objects appears larger
• Human vision!
Taxonomy of Projections
Parallel Projection
• For parallel projections, we specify a direction of
projection (DOP) instead of a COP
• Center of projection is at infinity
• Direction of projection (DOP) is the same for all points

DOP

View
Plane
Orthographic Projections
• DOP perpendicular to view plane

Front

Top Side
Oblique Projections
• DOP not perpendicular to view plane

 45  45

Cavalier Cabinet
o
(DOP  = 45 ) o
(DOP  = 63.4 )
Properties of parallel projection
• Properties of parallel projection:
• Are actually a kind of affine transformation
• Parallel lines remain parallel
• Ratios are preserved
• Angles not (in general) preserved
• Not realistic looking
• Good for exact measurements,
Most often used in
• CAD,
• architectural drawings,
• etc.,
where taking exact measurement
is important
Perspective projections
Properties of perspective projections
• Properties of projective transformations:
• Lines map to lines
• Parallel lines do not necessarily remain parallel
• Ratios are not preserved

• One of the advantages of perspective projection is that


size varies inversely with distance – looks realistic.

• A disadvantage is that we can't judge distances as exactly


as we can with parallel projections.
3D View Volume
• The volume in which the visible objects exist
• For parallel projection, view volume is a box.
• For perspective projection, view volume is a frustum.
• The surfaces outside the view volume must be clipped
Canonical View Volume

• We can transform the frustum view volume


into a normalized canonical view volume using
the idea of perspective transformation
• Much easier to clip surfaces and apply hidden
surface removal
Clipping and the viewing frustum
• The center of projection and the portion of the projection plane that map
to the final image form an infinite pyramid. The sides of the pyramid are
clipping planes.
• Frequently, additional clipping planes are inserted to restrict the range of
depths. These clipping planes are called the near and far or the hither
and yon clipping planes.

• All of the clipping planes bound the viewing frustum.


Clipping and the viewing frustum
• Notice that it doesn’t really matter where the image plane
is located, once you define the view volume
• You can move it forward and backward along the z axis
and still get the same image, only scaled

Usually d = near
Perspective Parameters
• There are three different ways to describe a perspective
camera
• Clipping planes, Field of View, Focal distance ,
• The most general is clipping planes – they directly
describe the region of space you are viewing
• For most graphics applications, field of view is the most
convenient
• You can convert one thing to another
Clipping Planes
The left/right/top/bottom planes are defined according to
where they cut the near clip plane Left Clip
Near Clip Plane
xv
Plane
Far Clip
View Plane
l Volume
n
f -zv
r

Right Clip
Plane
Need 6 parameters,
Or, define the left/right and top/bottom clip
planes by the field of view
Field of View
Assumes a symmetric view volume
Left Clip
Near Clip Plane
xv
Plane
Far Clip
View Plane
Volume
FOV
f -zv

Right Clip
Plane

Need 4 parameters,
Or, define the near, far, fov, aspect ratio
Focal Distance to FOV
• You must have the image size to do this conversion
• Why? Same d, different image size, different FOV

height/2

d FOV/2
d  FOV  height
tan  
 2  2d
 1  height 
FOV 2 tan  
 2d 

You might also like