You are on page 1of 38

3D Concepts 3D Transformations 3D Viewing

Chapter 3 - 3D Transformation and Viewing

by

Tesfamicael.W Arefaine

May 28, 2017

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 1 / 38


3D Concepts 3D Transformations 3D Viewing Display Method

3D Concepts
3D graphics deals with generating and displaying 3D objects in a 2D
space(display screen).
Considerations we must take in to account, When we model and
display a 3D scene.
1 Object boundaries: constructed with various combinations of plane
and curved surfaces.
2 Specify object interiors information.
3 3D rotation is more complicated as we can rotate an object an axis
with any special orientation.
4 Viewing transformation are more complicated because we have more
parameters to select.
5 Identified Visible parts of a scene and apply surface-rendering
algorithms.

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 2 / 38


3D Concepts 3D Transformations 3D Viewing Display Method

Display Method
To obtain a display of a 3D scene:
1 Set up a coordinate reference for the camera.
This coordinate reference defines the position and orientation for the
plane of the camera film, which is the plane we want to use to display
a view of the objects in the scene.
2 Object descriptions are then transformed to the camera reference
coordinates and Projected to the selected display plane.

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 3 / 38


3D Concepts 3D Transformations 3D Viewing Display Method

Parallel Projection:
Parallel lines in the world-coordinate scene projected into parallel
lines on the 2D display plane.
This technique is used in engineering and architectural drawings to
represent an object with a set of views that maintain relative
proportions of the object.

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 4 / 38


3D Concepts 3D Transformations 3D Viewing Display Method

Perspective Projection
Paralle lines in a scane that are not parallel to the display plane are
projected into converging lines.
This causes objects farther from the viewing position to be displayed
smaller than objects of the same size that are nearer to the viewing
position.
It provides more realistic scane, since this is the way that are eyes
and a camera lens form images.

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 5 / 38


3D Concepts 3D Transformations 3D Viewing Display Method

Depth Cueing
Depth information is important to identify, for a particular viewing
direction, which is the front and back of displayed objects.

Some ways to include depth info.


1 In wire-frame display vary the intensity of objects according to their
distance from the viewing position and is applied by choosing
maximum and minimum intensity (or color) values and a range of
distances over which the intensities are to vary.
2 Modelling the effect of the atmosphere on the perceived intensity of
objects. More distant objects appear dimmer to us than nearer
objects due to light scattering by dust particles, haze, and smoke.

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 6 / 38


3D Concepts 3D Transformations 3D Viewing Display Method

Visible Line and Surface Identification


Identifing visible lines:
1 Highlight the visible lines or display them in a different color, but
hidden surfaces are obscured.
2 Another technique, commonly used for engineering drawings, is
display the non visible lines as dashed lines.
3 Another approach is to simply remove the non visible lines, but it also
removes information about the shape of the back surfaces of an object
These visible-line methods also identify the visible surfaces of
objects.

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 7 / 38


3D Concepts 3D Transformations 3D Viewing Display Method

Surface Rendering
Added realism is attained in displays by setting the surface intensity
of objects according to
1 The lighting conditions in the scene
2 The assigned surface characteristics.
Lighting specifications include the intensity and positions of light
sources and the general background illumination required for a scene.
Surface properties of objects include degree of transparency and how
rough or smooth the surfaces are to be.

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 8 / 38


3D Concepts 3D Transformations 3D Viewing 3D Translations 3D Scaling 3D Rotation

3D Transformations

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 9 / 38


3D Concepts 3D Transformations 3D Viewing 3D Translations 3D Scaling 3D Rotation

3D Translations:
In a 3D homogeneous coordinate representation, a point is
translated from position P = (x, y, z) to position P’=(x’, y’, z’) with
the matrix operation.
     0
1 0 0 tx x x
0 1 0 ty  y  y 0  0
0 0 1 tz  ∗ z  = z 0  , P = T .P
     

0 0 0 1 1 1

Parameters tx , ty , and tz specify translation distances.


The matrix representation in the above is equivalent
x’=x + tx , y’=y + ty and z’=z + tz

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 10 / 38


3D Concepts 3D Transformations 3D Viewing 3D Translations 3D Scaling 3D Rotation

3D Scaling
Scaling changes the size of the object and reposition the object
relative to the coordinate origin.
     0
sx 0 0 0 x x
 0 sy 0 0 y  y 0  0
 0 0 sz 0 z  = z 0  , S.P = P
    

0 0 0 1 1 1

Preserve original shape if sx =sy =sz

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 11 / 38


3D Concepts 3D Transformations 3D Viewing 3D Translations 3D Scaling 3D Rotation

3D Scaling
Scaling with respect to a selected pixel position (xf , yf , zf ) can be
represented with the ff transformation:
1 Translate the fixed point to the origin.
2 Scale the object relative to the coordinate origin.
3 Translate the fixed point back to its original position.
The transformation matrix will be:
 
sx 0 0 (1 − sx )xf
 0 sy
 0 (1 − sy )yf 

0 0 sz (1 − sz )zf 
0 0 0 1

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 12 / 38


3D Concepts 3D Transformations 3D Viewing 3D Translations 3D Scaling 3D Rotation

3D Rotations
To generate rotation transformation for an object, we must
designate an axis of rotation and amount of angular rotation.
Unlike 2D rotation, where all the transformations are carried out in
the xy plane, a 3D rotation can be specified around any line in space.
Z-axis Rotation:
x’=x cosθ - y sinθ
y’=x sinθ + y cosθ
z’=z  
cosθ −sinθ 0 0
 sinθ cosθ 0 0
Rz (θ) = 
 0

0 1 0
0 0 0 1

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 13 / 38


3D Concepts 3D Transformations 3D Viewing 3D Translations 3D Scaling 3D Rotation

3D Rotations
X-axis rotation: Y-axis rotation:
x’=x x’=z sin θ + x cos θ
y’=y cos θ - z sin θ y’=y
z’=y sin θ + z cos θ z’=z cos θ - x sin θ

Permutation: Permutation:
x →y →z →x x →z →y →x
   
1 0 0 0 cosθ 0 sinθ 0
0 cosθ −sinθ 0  0 1 0 0
Rx (θ) = 
0 sinθ cosθ 0
 Ry (θ) = 
−sinθ

0 cosθ 0
0 0 0 1 0 0 0 1

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 14 / 38


3D Concepts 3D Transformations 3D Viewing 3D Translations 3D Scaling 3D Rotation

General 3D Rotations
A rotation matrix for any axis that does not coincide with a
coordinate axis can be set up as composite transformation of:
1 Translate the object so that the rotation axis passes through the
coordinate origin.
2 Rotate so that the axis of rotation coincides with one of the
coordinate axis.
3 Perform the specified rotation about the coordinate axis.
4 Apply inverse rotation to bring the rotation axis back to the original
coordinates.
5 Apply inverse translation to bring rotation axis back to its original
position.

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 15 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

3D Viewing
2D viewing
I Transfer positions from the world-coordiante plane to pixel positions
in the viewport of the output device
I Clipping boundaries - the four boundaries of the world coordinate
system
3D viewing
I It is more involved
I We can view an object from any spatial position: from front, from
above, from back, from within, ...
I 3D descriptions of objects must be projected onto the flat viewing
surface of the output device
I Clipping boundaries - a volume of space whose shape depends on the
type of projection

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 16 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Viewing Pipeline
The steps for computer generation of a view of a 3D scene are
somewhat analogous to the process involved in taking a photograph.
To take a snapshot:
1 Position the camera in space
2 Point the camera at the scene
3 Decide the camera orientation
4 On snapping the shutter,
The scene is cropped to the size of the aperture of the camera
Light from the visible surfaces is projected onto the camera film

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 17 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

The Camera Analogy


Steps taking a photograph with a camera (or a computer) might be
the following:
1 Set up your tripod and point the camera at the scene (viewing
transformation)
2 Arrange the scene to be photographed into the desired composition
(modelling transformation)
3 Choose a camera lens or adjust the zoom (projection transformation)
4 Determine how large you want the final photograph to be (viewport
transformation).

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 18 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Cont’

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 19 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Cont’
General 3D transformation pipeline, from modeling coordiantes to final
device coordinates.

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 20 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Specifying the view plane


We choose a particular view for a scene by first establishing the
viewing-coordinate system as in the fig below.
A view plane, or projection plane, is then set up perpendicular to the
viewing zv axis.

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 21 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Establising the viewing coordinate system


Pick a world coordinate position - view reference point - origin of the
viewing coordinate system
Select a positive direction for the viewing zv axis by specifying the
view plane normal vector, N
Choose the up direction for the view by specifying a vector V called
the view-up vector

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 22 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Different views of scene


keep the reference point fixed and change the direction of N.

Viewing a scene from different directions with a fixed view reference


ponit

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 23 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Viewing Transformation
Before object descriptions can be projected to the view plane, they
must be transferred to viewing coordinates
Transformation that superimposes the viewing reference frame onto
the world frame using the basic geometric transformations
1 Translate the view reference point to the origin of the
world-coordinate system
2 Apply rotations to align the xv , yv , and zv axes with the world xw ,
yw , and zw axes respectively

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 24 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Projections
Our eyes collapse 3-D world to 2-D retinal image
In this Computer graphics, this process is done with projection
Once world-coordianate descriptions of the objects in a scene are
converted to viewing coordinates, we can project the 3D objects on
to the 2D view plane

Projection types
1 Parallel projection - coordinate positions are transformed to the
view plane along parallel lines
2 Perspective projection - coordinate positions are transformed to
the view plane along lines that converge to a point called the
projection reference point
I The projected view of an object is determined by calculating the
intersection of the projection lines with the view plane

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 25 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Parallel and Perspective Projection

Perspective projection of an object


Parallel projection of an object to to the view plane
the view plane

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 26 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Parallel Projections
Preserve relative proportions of objects
Used in drafting to produce scale drawings of 3D objects
Don’t give us realistic representations of the appearance of 3D
objects
Specified with a projection vector that defines the direction of the
projection lines

Types of parallel projection


1 Orthographic projection - projection is perpendicular to the view
plane
2 Oblique projection - projection is not perpendicular to the view
plane

# OpenGL provides only orthographic projection

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 27 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Orthographic projection
Transform points along projection lines that
I are parallel
I have the focal point at infinity
I are orthogonal to the view plane
Camera analogy - telephoto lens

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 28 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Projection Equations
If the view plane is placed at position zvp along the zv axis, any
point (x, y , z) in viewing coordinates is transformed to projection
coordinates as
I xp = x
I yp = y
I zp = zvp
The original z-coordinate value is preserved for depth information
needed in
I depth cueing
I visible surface determination procedures

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 29 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Cont’

The projection matrix for orthographic


projection on to the xv yv plane can be
written as
 
1 0 0 0
0 1 0 0
Mparallel = 
0 0 0 0

Orthographic projection of a 0 0 0 1
point onto a viewing plane

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 30 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Perspective Projections
Don’t preserve relative proportions of objects
Produce realistic views
Projections of distant objects are smaller than projections of objects
of the same size that are closer to the projection plane
Transform points along projection lines that meet at the projection
reference point, zprp

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 31 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Projection Equations
1 Projection reference point - zprp along the zv axis
2 View plane - zvp
3 A point (x, y , z) is projected to the point (xp , yp , zp )

Perspective projection of a point P with coordinates (x, y, z) to position


(xp , yp , zp ) on the view plane.

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 32 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Top view and side view

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 33 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Projection equations
Using similarity of triangles in both the views, we obtain
x(d)
1 xp = zprp −z
y (d)
2 yp = zprp −z
3 zp =zvp
The perspective projection matrix can be written as follows
 
1 0 0 0
0 1 0 0 
−zvp zprp 
 
Mperspective = 
0 0 d zvp ( d )
 
−1 zprp
0 0 d d

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 34 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Perspective division
Applying the perspective projection matrix on a point (x, y , z)
results in new point (xh , yh , zh )
zprp −z
Dividing the point (xh , yh , zh ) by h= d results in the projected
point (xp , yp , zp )
The original z-coordinate value is retained in projection coordinates
for visible surface and other depth processing

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 35 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

View Volume
Given a view window - a view volume can be set up using the
boundaries of the view window
Size of view volume - depends on the size of the window
Shape of view volume - depends on the type of projection
1 parallel projection - an infinite parallelpiped
2 perspective projection - pyramid with apex at the projection reference
point

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 36 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Finite view volume


Obtained by limiting the extent of the volume in the zvp direction -
using two additional boundary planes
Front plane and back plane (near plane and far plane)
Parallel to the view plane at the specified positions zfront and zback
I Orthographic projection - rectangular parallelepiped
I Perspective projection - frustum

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 37 / 38


3D Concepts 3D Transformations 3D Viewing Viewing Pipeline Viewing Coordinates Projections

Parallelepiped view volume VS Frustum view volume

Tesfamicael.W Arefaine 3D Transformation and Viewing May 28, 2017 38 / 38

You might also like