You are on page 1of 40

Computer Graphics

Prepared By
K.Venkateswara Rao


CMRCET


Unit-6

Three-Dimensional Geometric and
Modeling Transformations
Computer Graphics
Three-Dimensional Geometric and
Modeling Transformations

Some Basics
3D Translations.
3D Scaling.
3D Rotation.
3D Reflections.
Transformations.

3D Point
We will consider points as column vectors.
Thus, a typical point with coordinates (x, y,
z) is represented as:
(
(
(

z
y
x
3D Translations.
P is translated to P' by T:

(
(
(
(

1 0 0 0
1 0 0
0 1 0
0 0 1
z
y
x
t
t
t
Called the
translation
matrix
T =
6
3D Translations.
(
(
(
(

(
(
(
(

=
(
(
(
(

1 1 0 0 0
1 0 0
0 1 0
0 0 1
1
'
'
'
z
y
x
t
t
t
z
y
x
z
y
x
P T P = '
7
3D Translations.
An object is translated in 3D
dimensional by transforming each of
the defining points of the objects.
3D Translations.
( )
z y x
t t t T , , =
( ) z y x , ,
( ) ' , ' , ' z y x
mshe1990@hotmail.com &&
9
Rotation
Positive rotation angles produce counterclockwise
rotations about a coordinate axis
mshe1990@hotmail.com &&
Rotation
mshe1990@hotmail.com &&
11
Coordinate-Axes Rotations
(
(
(
(

(
(
(
(


=
(
(
(
(

1 1 0 0 0
0 1 0 0
0 0 cos sin
0 0 sin cos
1
'
'
'
z
y
x
z
y
x
u u
u u
u u sin cos ' y x x =
u u cos sin ' y x y + =
z z = '
P R P
z
) ( ' u =
mshe1990@hotmail.com &&
12
Coordinate-Axes Rotations
(
(
(
(

(
(
(
(


=
(
(
(
(

1 1 0 0 0
0 cos sin 0
0 sin cos 0
0 0 0 1
1
'
'
'
z
y
x
z
y
x
u u
u u
u u sin cos ' z y z =
u u cos sin ' z y y + =
x x = '
P R P
x
) ( ' u =
mshe1990@hotmail.com &&
13
Coordinate-Axes Rotations
(
(
(
(

(
(
(
(

=
(
(
(
(

1 1 0 0 0
0 cos 0 sin
0 0 1 0
0 sin 0 cos
1
'
'
'
z
y
x
z
y
x
u u
u u
u u sin cos ' x z z =
u u cos sin ' x z x + =
y y = '
P R P
y
) ( ' u =
mshe1990@hotmail.com &&
14
General Three-Dimensional Rotations
An object is to be rotated about an axis that is parallel
to one of the coordinate axes
1. Translate the object so that the rotation axis coincides
with the parallel coordinate axis
2. Perform the specified rotation about that axis
3. Translate the object so that the rotation axis is moved
back to its original position
P T R T P
x
=

) ( '
1
u
T R T R
x
=

) ( ) (
1
u u
3D Scaling
P is scaled to P' by S:

Called the
Scaling matrix
S =
(
(
(
(

1 0 0 0
0 0 0
0 0 0
0 0 0
z
y
x
s
s
s
16
3D Scaling
Scaling with respect to the coordinate origin
(
(
(
(

(
(
(
(

=
(
(
(
(

1 1 0 0 0
0 0 0
0 0 0
0 0 0
1
'
'
'
z
y
x
s
s
s
z
y
x
z
y
x
P S P = '
3D Scaling
Scaling with respect to a selected fixed
position (x
f
, y
f
, z
f
)

1. Translate the fixed point to origin
2. Scale the object relative to the coordinate origin
3. Translate the fixed point back to its original position
(
(
(
(

=
1 0 0 0
) 1 ( 0 0
) 1 ( 0 0
) 1 ( 0 0
) , , ( ) , , ( ) , , (
f z z
f y y
f x x
f f f z y x f f f
z s s
y s s
x s s
z y x T s s s S z y x T
3D Scaling
3D Reflections
About an axis: equivalent to
180rotation about that axis
20
3D Reflections
(
(
(
(

=
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
z
RF
21
3D Shearing
Modify object shapes
Useful for perspective projections:
E.g. draw a cube (3D) on a screen (2D)
22
Shears
(
(
(
(

=
1 0 0 0
0 1 0 0
0 1 0
0 0 1
b
a
SH
z
3D Viewing
The steps for computer generation of a view of a three
dimensional scene are somewhat analogous to the
processes involved in taking a photograph.
Camera Analogy
Position
Orientation
Window (aperture)
of the camera
1. Viewing position
2. Camera orientation
3. Size of clipping
window
p_16_10 @hotmail.com it4ever2008
@hotmail.com 25
Viewing Pipeline
The general processing steps for modeling and
converting a world coordinate description of a
scene to device coordinates.
p_16_10 @hotmail.com it4ever2008
@hotmail.com 26
Viewing Pipeline

1. Construct the shape of individual objects in a scene within modeling
coordinate, and place the objects into appropriate positions within the scene
(world coordinate).
p_16_10 @hotmail.com it4ever2008
@hotmail.com 27
Viewing Pipeline
World coordinate positions are converted to
viewing coordinates.
p_16_10 @hotmail.com it4ever2008
@hotmail.com 28
Viewing Pipeline

Convert the viewing coordinate description of the
scene to coordinate positions on the projection
plane.
p_16_10 @hotmail.com it4ever2008
@hotmail.com 29
Viewing Pipeline

Positions on the projection plane, will then mapped
to the Normalized coordinate and output device.
Camera Modeling w/ OpenGL
glMatrixMode(GL_MODELVIEW)
...
glMatrixMode(GL_PROJECTION)
...
glViewport(0,0,xres,yres)
camera coordinate
system
viewport coordinate
system
device/screen
coordinate system
Viewing Coordinate System -
View Reference Point
In our world co-ordinate system,
we need to specify a view
reference point - this will become
the origin of the view co-ordinate
system
This can be any convenient point,
along the camera direction from
the camera position
indeed one possibility is the camera
position itself
Viewing Coordinate System -
View Plane Normal
x
W
y
W
z
W
P
0
N
Next we need to specify the view plane
normal, N - this will give the camera
direction.
Some graphics systems require you to
specify N ...
Viewing Coordinate System -
View Up Direction
Finally we need to specify
the view-up direction, V -
this will give the y-axis
direction
x
W
y
W
z
W
P
0
N
V
Projections
Once the view volume is
determined, a projection
transformation will
convert the object in the
3D view volume to a 2D
image on the projection
plane.
Parallel projection
Coordinate positions are transformed to the view plane
along parallel lines
Perspective projection
36
Object positions are transformed to the view plane along lines
that converge to a point called the projection reference point.
Projection vector that defines the direction for the
projection lines.
When the projection is perpendicular to the view plan,we
have an orthographic projection.
Otherwise we have oblique parallel projection.
Parallel projections
37
Orthographic projection of an object
p_16_10
@hotmail.co
m
it4ever2008
@hotmail.co
m
39
Perspective Projection (1/2)
Give a realistic view of 3D objects, but does not
preserve shape of object or scale
Perspective images of parallel lines not parallel
with projection plane converge to a point called
vanishing point
Size of object is diminished with distance
Used in architectural, engineering, industrial
design, and advertising drawings
40
Perspective Projection (2/2)
3-point perspective
1-point perspective
2-point perspective
Most popular

You might also like