3D Transformations

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 25

Computer Graphics

3D Transformations
From 2D to 3D
• Translation is simple as in 2D
• Use of Homogeneous coordinate in 3D
– In 3D transformation always use Matrix: 4x4
• All transformation in 3D is simple but only
Rotation transformation is complex in 3D
transformation.
3D Translation
Translate using (tx, ty, tz ): y

x’=x+ tx, y’=y+ ty , z’=z+ tz P+T


T
or P
P' P  T, met
x
 x'   x  tx 
     
P '  y '  , P  y  en T  t y 
z
 z'   z t 
     z
3D Translation 2
In 4D homogeneous coordinates: y

P' MP, or T P+T

 x'   1 0 0 t x  x  P
     x
 y'  0 1 0 t y  y 
 z '   0 0 1 t z  z 
     z
 1  0 0 0 1   1 
  
3D Rotation 1
Rotate over angle  around z - as :
x' x cos   y sin 
y ' x sin   y cos  z
y
z ' z P’
Or 
P' R z ( )P, with P
 cos   sin  0 0 x
 
 sin  cos  0 0
R z ( ) 
0 0 1 0
 
 0 0 0 1 

2D Rotation about the origin.
x r. cos(   ) r. cos  . cos  r. sin  . sin 
y y r. sin(   ) r. cos  . sin   r. sin  . cos

P’(x’,y’)

P(x,y)
r x r. cos 
y r. sin 
 y
r

x
x
3D Rotation 2

z y z y z y

x x x

Rotation around axis:


- Counterclockwise, viewed from rotation axis
3D Rotation 3

z x z x y
z y y z y
x y y z
y z z x
x x x

Rotation around axes:


Cyclic permutation coordinate axes
x y z x
3D Rotation
Rotate over angle  around z - as : Rotate over angle  around x - as :
x' x cos   y sin  y '  y cos   z sin 
z x
y ' x sin   y cos  z '  y sin   z cos 
x y x' x
z ' z
Or y z Or
P' R z ( )P, with P' R x ( )P, with
 cos   sin  0 0 1 0 0 0
   
 sin  cos  0 0  0 cos   sin  0
R z ( )  R x ( ) 
0 0 1 0 0 sin  cos  0
   
 0 0 0 1  0 0 0 1 
 
3D scaling
Scale with factors sx, sy,sz :
x’= sx x, y’= sy y, z’= sz z
or P' SP, or
 x'   s x 0 0 0  x 
    
 y'  0 sy 0 0  y 
 z '   0 0 sz 0  z 
    
1  0 0 0 1   1 
  
3D scaling
3D Shearing about X,Y,Z Axis
 1 0 0 0  1 Shx 0 0  1 0 Shx 0 
 shy 1 0 0   0 1 0 0 0
    1 Shy 0 
 shz 0 1 0  0 Shz 1 0  0
  0 1 0
   
 0 0 0 1  0 0 0 1 0 0 0 1
• Shearing about X axis- X coordinate will not change but
change in Y and Z axis coordinate.
• Shearing about Y axis- Y coordinate will not change and
changes are made only in X and Z axis.
• Shearing about Z axis- Z coordinate will not change but
change in X and Y axis.
Combine 3D Transformation
3D Combine Transformations
Rotation About axis that is parallel to
X-axis
3D Rotation around arbitrary axis 2
Rotation around axis through two points P1 and P1 .
More complex:
1.Translate such that axis goes through origin;
2.Rotate…
3.Translate back again.
y P2

P1

z x

H&B 9-2:305-313
3D Rotation around arbitrary axis 3
y P2 y P2'
y

P1 P1' P1'
x x z x
z z ''
P
2

Initial 1. translate axis 2. rotate axis


y y P2' y P2

P1' P1' P1
z x x
''
P
2 z z x
3. rotate around 4. rotate back 5. translate back
z-axis
3D Rotation around arbitrary axis 3
y P2 y P2'
y

P1 T(P1) ' R
P' P
1
1

x x z x
z z ''
P
2

Initial 1. translate axis 2. rotate axis


y y P2' y P2
Rz()
' R1 T(P1)
P1 P' P1
1
z x x
''
P
2 z z x
3. rotate around 4. rotate back 5. translate back
z-axis
3D Rotation around arbitrary axis 3
M = T(P1) R1Rz() RT(P1)
y P2 y P2'
y

P1 T(P1) ' R
P' P
1
1

x x z x
z z ''
P
2

Initial 1. translate axis 2. rotate axis


y y P2' y P2
Rz()
' R1 T(P1)
P1 P' P1
1
z x x
''
P
2 z z x
3. rotate around 4. rotate back 5. translate back
z-axis
Question
• Translate a Pyramid whose coordinates are
(0,0,0), (1,0,0) (0,0,1) and (0,1,0). Translate
this pyramid 3 unit x, y, z direction and find
out final transformed matrix.
Thank You!!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy