Computer Graphics
Computer Graphics
Computer Graphics
Three dimensional transformations
contents
Introduction
Translation
Scaling
scaling in 3D relative to the coordinate origin
Scaling relative to fixed point
Rotation
Rotation about the X-Axis
Rotation about the Y-Axis
Rotation about the Z-Axis
Rotation about an arbitrary axis
Rotation axis is parallel to one of the coordinate axes
Rotation axis is not parallel to one of the coordinate axes
Shearing
X-Shearing
Y-Shearing
Z-Shearing
introduction
Transformations are very useful in computer graphics in a number of
situations:
A scene can be fashioned by placing a number of instances of an
object at different places and with different sizes using proper
transformation.
Helps a designer to view an object from different points and make a
picture from each one.
In a computer animation, several objects must move relative to one
another from frame to frame.
Sometimes we need to reduce the size of an object or To place it
into a larger displays .
• these various manipulations are carried out by applying appropriate
geometric transformation
Translation
• In 3d Homogeneous Coordinate
representation,a point is translated from
position (x,y,z) to position (x’,y’,z’)with the
translation matrix :
1 0 0 Tx
0
1 0 Ty
T
0 0 1 Tz
0 0 0 1
Translation
y
(x’,y’,z’) y
T=(Tx,Ty ,Tz )
(x,y,z)
z x
z x
Translating a point with translation vector T=(Tx,Ty ,Tz )
x Sx 0 0 0 x
y 0 Sy 0 0 y
z 0 0 Sz 0 z
1 0 0 0 1 1
This matrix is equivalent to the
Three equations:
X’ = x . Sx
Y’ = y . Sy
Z’ = z . Sz
scaling
z x
scaling
Y
X
Rotation about the X-Axis
Rx ;
Rotation about the Y-Axis
Ry ;
Rotation about the Z-Axis
Rz ;
Rotation about an arbitrary
axis
Rotation axis
z x
x
z
A - Original position of object B - Translate rotation axis onto x axis
Rotation about an arbitrary
axis
y
y
Rotation axis
z x
x
z
V1= (x1,y1,z1) V1
X X
Z Z
vectors specified relative
Vector addition
to the coordinate origin .
Vector multiplication
v =(v.v)**.5 = ( x . x + y. y+ z . z) **.5
V1 .V2 = V1 V2 cos(ө)
Vector multiplication
V1* V2 =u v1 v2 sinө
ux uy uz
x1 y1 z1
V1* V2 = x2
y2 z2
the Vector product produces a Vector with components :
(y1z2 – z1y2 , z1x2 - x1z2 , x1y2 – y1x2 )
Transformation matrices
1. Translate the object so that the rotation axis passes through the
coordinate origin.
2. Rotate the object so that the axis of rotation coincides with one of the
coordinate axis .
3. Perform the specified rotation .
4. Apply inverse rotations to bring the rotation axis back to its original
orientation .
5. Apply the inverse translation to bring the rotation axis back to its
original position.
Rotation about an arbitrary
axis
We can transform the rotation axis onto any of the three coordinate axes
For getting the rotation axis onto the z axis.
assume that the rotation axis is defined by two points as following :
V =(x2- x1 , y2 – y1 , z2 – z1 )
y
(x2,y2,z2)
U= v = (a, b,c)
v
u
(x1,y1,z1)
A= xv
B= yv
z x
C = zv
Rotation about an arbitrary
axis
1. Translate the object so that the rotation axis passes through the coordinate origin
Is accomplished with the translation matrix
1 0 0 0
0 1 0 0
T
0 0 1 0
X 1 Y1 Z1 1
Next we need the transformations that will put the rotation axis on the z axis.
In two steps :
a- rotate about the x axis so that vector u is in the xz plane .
b- rotate about the y axis to bring u onto the z axis
Rotation about an arbitrary
axis
y
y
z x
z u x
u '.u z c y
cos( )
u' uz d
U’ = (0,b,c) U = (a ,b,c)
d (b.b c.c) 1/ 2
u 'u z u x u ' u z sin( )
b z u z= (0 ,0,c) x
sin( )
d
Rotation about an arbitrary
axis
Now after determine sin( ) and cos( ) we Can evaluate the rotation
Matrix about the x axis as
1 0 0 0
c b
0 d d
0
RX ( ) b c
0 0
d d
0 0 0 1
Rotation about an arbitrary
axis
To determine the angle of the rotation about y axis
u ' '.u z
cos( ) d y
u' ' uz
u ' 'u z u y u ' ' u z sin( )
u ' 'u z u y .( a ) u z =(0,0,c)
sin( ) = - a z x
U’’ =(a,0,d)
Rotation about an arbitrary
axis
The transformation matrix for rotation about the y axis is
d 0 a 0
0 1 0 0
R y ( )
a 0 d 0
0 0 0 1
Now can be applied rotation about the z axis
cos( ) sin( ) 0 0
sin( ) cos( ) 0 0
Rz ( )
0 0 1 0
0 0 0 1
Rotation about an arbitrary
axis
R ( ) T RX ( ) R y ( ) Rz ( ) R y 1 ( ) RX 1 ( ) 1
T
Shearing
A shear transformation consists of shearing in each of the
three coordinate planes: the XY, XZ, and YZ planes.
A shear in the XY plane translates every plane parallel to
the XY plane by an amount in x and y proportional to the
z value of that plane.
X-Shearing
• X-shearing a
point
• Y-shearing a point
• Z-shearing a point