Sie sind auf Seite 1von 32

welcome

3D
TRANSFORMATIONS
What is a Transformation

• A process in which the vertices coordinates


are changed
• This is done by multiplying the coordinates
of each vertex by a transformation matrix
• Different transformations call for different
transformation matrices
Kinds of Transformations

• Translation
• Rotation
• Reflection
• Scaling
• Shearing
Translation
 Translation means moving an object to new
postion.
 It is also called off-setting
Translation
• If a point p(x,y,z) in 3D is moved to p’(x’,y’,z’) by
translated vector=<tx,ty,tz>,tx,ty,tz are
displacments of P along three principal directions
x,y,z resp.
Algebraically,
x’=x+tx
y’=y+ty
z’=z+tz
Matrices
Representation y

 x  1 0 0 tx   x P
 y   0  
1 0 t y   y x
   P
 z   0 0 1 tz   z  z
      y
 1  0 0 0 1  1 

x
P  T  P z
Scaling
Scaling means either reduces or enlarges an
object.

Objects are scaled by specifying a percentage


of scaling ,direction, and a pivot point.

Scaling in 3d can be carried out by multiplying


coordinate values (x ,y ,z ) by scaling factors sx ,
sy ,sz resp. to produce coordinates (x’,y’,z’).
Scaling
Matrices
Representation
y
P
P
x

z
y

P  S  P
x

z
Scaling with respect to a
Fixed Point
The process of scaling w.r.t fixed point involves
following steps:
1. Translate fixed point to origin.
2. Perform scaling.
3. Translate fixed point back to its original
postion.
Scaling with respect
to a Fixed Point
P  T( x f , y f , z f )  S  T( x f , y f , z f )  P
y y x
y y

x
x x
z z z
z

Translate Scale Translate back


Scaling with respect to a
Fixed Point
1 0 0 x f  sx 0 0 0 1 0 0 xf 
0 1 0 y f   0 sy 0 0 0 1 0 y f 
T( x f , y f , z f )  S  T(  x f ,  y f ,  z f )   
0 0 1 zf  0 0 sz 0  0 0 1 zf 
    
0 0 0 1  0 0 0 1  0 0 0 1
1 0 0 x f   s x 0 0  s x x f 
0 1 0 y   0 s 0  s y 
 f  
 y y f 

0 0 1 z f   0 0 s z  s z z f 
   
 0 0 0 1   0 0 0 1 
sx 0 0 x f (1  s x ) 
0 sy 0 y f (1  s y )
 T( x f , y f , z f )  S  T(  x f ,  y f ,  z f )  
0 0 sz z f (1  s z ) 
 
0 0 0 1 
ROTATION

A rotation specifies pivoting or angular


displacement about an axis.
Objects are rotated by specifying
•Angle of rotation
•A pivot point
Trigonometric functions are used to
determine the new postion.
ROTATION
3D rotation transformation is defined by specifying:
An axis of rotation
An angle of rotation is always perpendicular to the axis of
rotation.
ROTATION
• Rotation around the coordinate axes
y y y

x x x

z z z

x axis y axis z axis

Counterclockwise when looking along


the positive half towards origin
Rotation around the
coordinate axes
• ROTATION ABOUT X-AXIS
rotation of any point P(x,y,z) about x-axis by
an amount Ө is represented by
y‫=׳‬ycosө - zsinө
z‫=׳‬ycosө+ zcosө
x‫=׳‬x
Rotation around the
coordinate axes
• ROTATION ABOUT Y-AXIS
rotation of any point p(x,y,z) about y-axis
by an amount Ө is represented by

z‫=׳‬zcosө- xsinө
x‫=׳‬ysinө +xcosө
y‫=׳‬y
Rotation around the
coordinate axes
• ROTATION ABOUT Z-AXIS
rotation of any point P(x,y,z) about z-axis by
an amount Ө is represented by

x‫=׳‬xcosө-ysinө
y‫=׳‬xsinө+ycosө
z‫=׳‬z
Matrices
Representation
• Around x 1 0 0 0 P  R x ( )  P
0 cos  sin  0
R x ( )  
0 sin  cos 0
 
0 0 0 1
 cos 0 sin  0
 0 1 0 0
• Around y R y ( )   P  R y ( )  P
 sin  0 cos 0
 
 0 0 0 1

cos  sin  0 0
 sin  cos 0 0
• Around z R z ( )   P  R z ( )  P
 0 0 1 0
 
 0 0 0 1
ROTATION AROUND A
PARALLEL AXIS
• Rotating the object around a line parallel to one of
the axes: Translate to axis, rotate, translate back.
P  T(0, y p , z p )  R x ( )  T(0, y p , z p )  P
y y y y

x
x
x x
z z z
z

Translate Rotate Translate back


Rotation Around an
Arbitrary Axis
• Translate the object so that
the rotation axis passes
y
though the origin
• Rotate the object so that the
rotation axis is aligned with x
one of the coordinate axes
z
• Make the specified rotation
• Reverse the axis rotation
• Translate back
Rotation Around an Arbitrary Axis
Rotation Around an
Arbitrary Axis
V  P2  P1  ( x2  x1 , y2  y1 , z2  z1 )

u is the unit vector along V:

V
u  (a, b, c)
V
Where the components a,b,c of unit
vecter u are the direction cosines for
rotation axis
a=x2-x1
|V|

b=y2-y1
|V|
c=z2-z1
|V|
Reflection
• A reflection is transformation that produces a
mirror image of obect.

• A 3D reflection can be performed relative to a


selected reflection axis or w.r.t to a seleceted
reflection plane.

• Reflections relative to a plane are eqvivalent to


180 rotations infour –dimensional .
SHEAR
• Shearing transformation can be used to
modify objects shapes.
• The shear transformation causes the image to
slant.
• It is also called twist or torque or tilt
transformation.
SHEAR
• An example of 3D shearing,the
following transformation produces a z-
axis shear
1 0 a 0
0 1 b 0
SHz x and yvalue depends on z value of the shape
0 0 1 0
0 0 0 1
• Parameters a and b can be assigned any real
values.

• The effect of this transformation matrices is to


alter x and y coordinate values by an amount
that is proportional to the z value, while z
coordinate unchanged.

• Boundaries of planes that are perpendicular to z


axis are thus shifted by an amount proportional
to z.
THANKS

Das könnte Ihnen auch gefallen