You are on page 1of 22

CS 010 703 - Computer Graphics

Module-3
3D TRANSFORMATIONS
Basic 3D Transformations
Matrix representations, homogeneous coordinates
Composite Transformations
3D Transformations
Methods for geometric transformations and object modeling in 3D are
extended from 2D by including z-coordinates
In 3D space any spatial orientation can be selected
Any sequence of transformations (translation, rotation, scaling, etc)
can be represented as a single matrix, formed by concatenating
individual transformation matrices in the sequence
Very similar to 2D. Using 4x4 matrices rather than 3x3
An Object represented as a set of polygon surfaces, is translated by
translate each vertex of each surface and redraw the polygon facets
in the new position

April 2010 2
3D Coordinate Systems

Right Hand Left Hand


coordinate system: coordinate system:
3D Translation
Repositioning an object along a straight line path from one co-
ordinate location to another
(x, y, z) (x, y, z)
To translate a 3D position, we add translation distances tx ,ty and
tz to the original coordinates (x,y,z) to obtain the new
coordinate position (x,y,z)
x= x + tx , y= y + ty , z= z + tz
Matrix form (4 4)

x t x y
1 0 0 x
y 0 1 0 t y
y
z
0 0 1 t z
z T(tx, ty, tz)
1
1
0 0 0 1 x

P T (t x , t y , t z ) P z 4
3D Rotation
Rotations are specified by a rotation axis and an angle.
The easiest rotation axes are those that 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

April 2010 5
3D Rotation y
z-axis
2D z-axis rotation equations extended to 3D.
x
x x cos y sin z
y x sin y cos
z z
Matrix form
y
x cos sin 0 0 x
y sin cos 0 0
y
z 0 0 1 0
z
1 0 0
0 1
1
x

z

P Rz ( ) P 6
3D Rotation
x-axis y

y y cos z sin
z y sin z cos
x x x

z
Matrix form

x 1 0 0 0 x
y 0 cos sin 0
y
0 sin
z cos 0
z
1 0 0 0 1 1

P Rx ( ) P 7
3D Rotation
y-axis y

z z sin x cos
x z sin x cos
y y x

z
Matrix form

x cos 0 sin 0 x
y 0 1 0 0 y
z sin 0 cos 0 z
1 0 0 0 1 1

P Ry ( ) P 8
General Rotation About the Origin
A rotation by about an arbitrary axis can be decomposed into
the concatenation of rotations about the x, y, and z axes
R() = Rz( z) Ry( y) Rx( x)
x y z are called the Euler angles

April 2010 9
General 3D Rotation ( axis parallel)
Rotation axis parallel to one of the coordinate axes
Transformation sequence same as that of 2D rotation about
an arbitrary pivot point
1. Translate the object such that rotation axis coincides with the
parallel Cartesian axis.
2. Perform specified rotation about that Cartesian axis.
3. Apply inverse translation to return rotation axis back to its
original position

P' = R( P
= T-1 Rx() T P
(where R( T-1 Rx() T)

April 2010 10
General 3D Rotation ( axis parallel)

April 2010 11
General 3D Rotation (axis not parallel)
Rotation axis not parallel to any of the coordinate axes
A rotation matrix for any axis that does not coincide with a
coordinate axis can be set up as a composite transformation
involving combination of translations and the coordinate-axes
rotations.
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.
1 1 1
R ( ) T
April 2010 R x ( ) R y ( ) R z ( ) R y ( ) R x ( ) 12T
General 3D Rotation (axis not parallel)

April 2010 13
3D Scaling (about origin)
About origin: Changes the size of y y
the object and repositions the
object relative to the coordinate
origin.
Enlarging object also moves it
away from origin z x z x

x x S x x sx 0 0 0 x

y y S y y 0 sy 0 0 y
z 0 0 sz 0 z
z x S z
1 0 0 0 1 1

April 2010 P S ( s x , s y , s z ) P 14
3D Scaling w.r.t to a fixed point
Scaling with respect3D
to aScaling
fixed point (not necessarily of object)
Steps
1. Translate object such that fixed point moves to origin
2. Scale object about origin
3. Translate fixed point back to original position

Sx 0 0 1 S x x f

T S
T 1 0 Sy 0 1 S y y f

0 0 Sz 1 S z z f
0 0 0 1

T( x f , y f , z f ) S ( s x , s y , s z ) T( x f , y f , z f )
15
3D Scaling w.r.t to a fixed point

April 2010 16
3D Reflection
3D reflections can be performed wrt a
y
reflection axis or a reflection plane
Reflection About an axis: equivalent to
180rotation about that axis
Reflection About a plane: equivalent to x
180rotations in 4D space
z
Reflection about z-axis or xy plane

x 1 0 0 0 x
y 0 1 0
0 y

z 0 0 1 0
z
1 0 0 0
1 1
17
3D Shearing
Modify object shapes
Useful for perspective projections:
E.g. draw a cube (3D) on a screen (2D)
Z-axis shear: Alter the values for x and y by an amount
proportional to the distance from zref
Boundaries of planes perpendicular to the z-axis are shifted by
an amount proportional to z.
3D Shearing

1 0 shzx shzx z ref


0 1 shzy shzy z ref
M zshear
0 0 1 0
0 0 0 1
Composite 3D Transformations
We can represent any sequence of transformations as a single
matrix.
No special cases when transforming a point matrix vector.
Composite transformations matrix matrix.
3D Same way as in 2D:
Multiply matrices
Rightmost term in matrix product is the first transformation
to be applied
Composite transformations:
Rotate about an arbitrary point translate, rotate, translate
Scale about an arbitrary point translate, scale, translate
Change coordinate systems translate, rotate, scale
But the order of operations important
Transformations Between Coordinate Systems
Translate such that the origins overlap
Rotate such that the axes overlap

u ' x1 u ' x 2 u ' x3 0


u ' y1 u ' y 2 u ' y 3 0
R T T x0 , y 0 , z 0
u ' z1 u ' z 2 u ' z 3 0
0 0 0 1
y
y'

uy '
( x0 , y0 , z0 ) ux ' x'
(0,0,0) x
uz '

z z'
Coordinate System Transformations
We often need to transform points from one coordinate system
to another:
1.We might model an object in non-Cartesian space (polar)
2.Objects may be described in their own local system
3.Other reasons: textures, display, etc

You might also like