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

Computer Graphics: 3D-Transformations

The document discusses various 3D transformations including translation, scaling, rotation, and reflection. Translation moves an object by adding offsets to the x, y, and z coordinates. Scaling enlarges or shrinks an object by multiplying the coordinates by scaling factors. Rotation rotates an object around an axis by applying a rotation matrix. Reflection mirrors an object across an axis or plane by reversing coordinate values.

Uploaded by

Wafa Elgalhoud
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
339 views

Computer Graphics: 3D-Transformations

The document discusses various 3D transformations including translation, scaling, rotation, and reflection. Translation moves an object by adding offsets to the x, y, and z coordinates. Scaling enlarges or shrinks an object by multiplying the coordinates by scaling factors. Rotation rotates an object around an axis by applying a rotation matrix. Reflection mirrors an object across an axis or plane by reversing coordinate values.

Uploaded by

Wafa Elgalhoud
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 30

Computer Graphics

3D-Transformations
Translation

• The translation matrix of point (x,y,z) to


position (x’,y’,z’) :
1 0 0 Tx 
0 1 
0 Ty 
T
0 0 1 Tz 
 
0 0 0 1
Where :
Tx,Ty,Tz : translation distances for the coordinates
Translation

The new point :





x 1 0 0 Tx  x 
 
   
y 0

    y
1 0 Ty   


  



 
z  0


0 1 
Tz   z 
    
 
 1 

0
 0 0 1  1 


this matrix is equivalent to the Three equations:


X’ = x + Tx
Y’ = y + Ty
Z’ = z + Tz
Translation

(x’, y’, z’)


(x, y, z)

Fig 1 . Translating a point with translation vector T=(Tx,Ty ,Tz )


Translation

• Object translation

 An object is translated in three dimensions


by transforming each defining point of the
object .
 Translation of an object represented as a set
of polygon surfaces is carried out by
translating the coordinate values for each
vertex of each surface .
Translation

(x’,y’,z’)

T=(Tx,Ty ,Tz )

(x,y,z)

z
x

Translating an object with translation vector T=(Tx,Ty ,Tz )


Scaling

The scaling matrix :

 Sx 0 0 0
 0 Sy 0 0
S
 0 0 Sz 0
 
0 0 0 1

Where :
Sx,Sy and Sz are assigned are any positive values
Scaling relative to the origin coordinate

• The matrix operation for scaling in 3D relative


to the origin coordinate is

 x   Sx 0 0 0  x 
 y   0 Sy 0   
0  y 
 
 z   0 0 Sz 0  z 
    
1  0 0 0 1  1 

Where Sx,Sy, and Sz are assigned any positive values. and we obtain:
x’ = x . Sx y’ = y . Sy z’ = z . Sz
Scaling

this object is scaled and moved relative to coordinate origin.

z
x
Scaling

Doubling the size of an object


Scaling

• Uniform scaling
• when (Sx = Sy =Sz) the original shape is preserved.
y y

x x

• If transformation parameters are not all equal


then the object are also changed.
Scaling about a fixed point
Scaling about a fixed point P (xF ,yF,zF) can be
accomplished by the following:
1. translating P to the origin
2. scaling the object
3. translating P back to original position.
The composite matrix is
T(-xF,-yF,-zF)*(S(Sx,Sy,Sz))*(T(xF,yF,zF))
Scaling about a fixed point
 Translate the fixed point to the origin with
 1 0 0 0
 0 1 0 0
T
 0 0 1 0
 
  Tx  Ty  Tz 1
y
y

x
z
x z
(1) (2)
Scaling about a fixed point
 Scale with  Sx 0 0 0 y
 0 Sy 0 0
S
 0 0 Sz 0
  z
x
0 0 0 1 (3)

 Translate the fixed point back to its the original position with
1 0 0 0 y
0 1 0 0
T
0 0 1 0 x
  (4)
Tx Ty Tz 1 z
Scaling about a fixed point

The result :

 Sx 0 0 0
 0 S 0 
0
S
y

 0 0 Sz 0
 
(1  Sx) X F (1  Sy )Y F (1  Sz ) Z F 1
Rotation
 3D Rotation is more complicated than 2D.
 we must specify an axis of rotation.
 In 2D the axis of rotation is always
perpendicular to the xy plane.
 in 3D, the axis of rotation can have any spatial
orientation.
 The amount of angular rotation:
 Positive values for the angle indicate a
counterclockwise rotation.
 Negative values for the angle rotate objects in
clockwise direction.
Rotation about the Z-Axis

(x, y,0) (x,y,0)

 x   cos   sin  0 0  x 
    
 y   sin  cos  0 0  y 
 z    0 0 1 0  z 
    
1  0 1  1 
   0 0
Rotation about the X-Axis

 x   1 0 0 0  x 
    
 y   0 cos  sin  0  y 
   
 z   0 sin  cos 0  z 
    
 1  0 0 0 1  1 
Rotation about the Y-Axis

 x   cos  0 sin  0  x 
    
 y   0 1 0 0  y 
 z      sin  0 cos  0  z 
    
1  0 1  1 
   0 0
Rotation about an arbitrary axis

I . In the special case where the selected rotation


axis 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.
3. Translate the object so that the rotation axis
is moved back to its original position .
Rotation about an arbitrary axis
Rotation about an arbitrary axis
II, when the selected rotation axis is not parallel to
one of the coordinate axes.
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
3D Reflections

• Reflections can be performed relative to a selected


axis or relative to a selected plane.
• Reflection with respect to an axis is equivalent to a
180˚ rotation about that axis.
3D Reflections
• A reflection about the xy plane reverses the sign of the z-
coordinates, leaving the x and y coordinates unchanged.

1 0 0 0

0 1 0 0

RFz = 0 0 -1 0

0 0 0 1
3D Reflections
• A reflection about the yz plane reverses the sign of the x-
coordinates, and a reflection about the xz plane reverses the
sign of the y-coordinates.

-1 0 0 0 1 0 0 0
0 1 0 0 0 -1 0 0
RFx = 0 0 1 0 RFy = 0 0 1 0
0 0 0 1 0 0 0 1
3D Shears
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.
Y
Y

Z
Z
3D Shears

• A 3D shear relative to the z-axis is accomplished by:

1 0 shzx 0

0 1 shzy 0
M-Shear z = 0 0 1 0

0 0 0 1
3D Shears

• A 3D shear relative to the x-axis and y-axis are


accomplished by:

1 0 0 0 1 shyx 0 0
shxy 1 0 0 0 1 0 0
M-Shearx = M-Sheary =
shxz 0 1 0 0 shyz 1 0
0 0 0 1 0 0 0 1
References
• Donald Hearn, M. Pauline Baker Computer
Graphics (0-13-165598-1)
• http://www.cs.kuleuven.ac.be/~graphics/H331/
• http://www.siggraph.org/education/aterials/Hyper
Graph
• http://www.cosc.brocku.ca/Offerings/3P98/course/l
ectures/2d_3d_xforms/

You might also like