Post on 19-May-2015
Graphics
sudipta.hit@gmail.com
3D GeometricTransformation
Sudipta Mondal
BCET
sudipta.hit@gmail.com
Contents
n Translation
n Scaling
n Rotation
n Rotations about an arbitrary axis in space
n Other Transformations
n Coordinate Transformations
BCET
sudipta.hit@gmail.com
Transformation in 3D
n Transformation Matrix
úúúú
û
ù
êêêê
ë
é
´´
´´Þ
úúúú
û
ù
êêêê
ë
é
1131
1333
000 SLIFCKHEBJGDA
3´3 : Scaling, Reflection, Shearing, Rotation3´3 : Scaling, Reflection, Shearing, Rotation
3´1 : Translation3´1 : Translation
1´3 : Homogeneous representation1´3 : Homogeneous representation
1´1 : Uniform global Scaling1´1 : Uniform global Scaling
BCET
sudipta.hit@gmail.com
3D Translation
n Translation of a Point
zyx tzztyytxx +=+=+= ',','
úúúú
û
ù
êêêê
ë
é
úúúú
û
ù
êêêê
ë
é
=
úúúú
û
ù
êêêê
ë
é
11000100010001
1'''
zyx
ttt
zyx
z
y
x
xz
y
BCET
sudipta.hit@gmail.com
3D Scaling
n Uniform Scaling
zyx szzsyysxx ×=×=×= ',','
úúúú
û
ù
êêêê
ë
é
úúúú
û
ù
êêêê
ë
é
=
úúúú
û
ù
êêêê
ë
é
11000000000000
1'''
zyx
ss
s
zyx
z
y
x
xz
y
BCET
sudipta.hit@gmail.com
Relative Scaling
n Scaling with a Selected Fixed Position
úúúú
û
ù
êêêê
ë
é
úúúú
û
ù
êêêê
ë
é
---
úúúú
û
ù
êêêê
ë
é
úúúú
û
ù
êêêê
ë
é
=
úúúú
û
ù
êêêê
ë
é
=---××
11000100010001
1000000000000
1000100010001
1'''
),,(),,(),,(zyx
zyx
ss
s
zyx
zyx
zyxTsssSzyxTf
f
f
z
y
x
f
f
f
fffzyxfff
x x x xzzzz
y y y y
Original position Translate Scaling Inverse Translate
BCET
sudipta.hit@gmail.com
3D Rotation
n Coordinate-Axes Rotationsn X-axis rotationn Y-axis rotationn Z-axis rotation
n General 3D Rotationsn Rotation about an axis that is parallel to one of the
coordinate axesn Rotation about an arbitrary axis
BCET
sudipta.hit@gmail.com
Coordinate-Axes Rotations
n Z-Axis Rotation n X-Axis Rotation n Y-Axis Rotation
úúúú
û
ù
êêêê
ë
é
úúúú
û
ù
êêêê
ë
é -
=
úúúú
û
ù
êêêê
ë
é
11000010000cossin00sincos
1'''
zyx
zyx
qqqq
z
y
x
úúúú
û
ù
êêêê
ë
é
úúúú
û
ù
êêêê
ë
é-
=
úúúú
û
ù
êêêê
ë
é
110000cossin00sincos00001
1'''
zyx
zyx
qqqq
úúúú
û
ù
êêêê
ë
é
úúúú
û
ù
êêêê
ë
é
-=
úúúú
û
ù
êêêê
ë
é
110000cos0sin00100sin0cos
1'''
zyx
zyx
z
y
xz
y
x
BCET
sudipta.hit@gmail.com
Order of Rotations
n Order of Rotation Affects Final Positionn X-axisè Z-axis
n Z-axisè X-axis
BCET
sudipta.hit@gmail.com
General 3D Rotations
n Rotation about an Axis that is Parallel to One ofthe Coordinate Axesn Translate the object so that the rotation axis
coincides with the parallel coordinate axisn Perform the specified rotation about that axisn Translate the object so that the rotation axis is
moved back to its original position
BCET
sudipta.hit@gmail.com
General 3D Rotations
n Rotation about an Arbitrary Axis
Basic Idea1. Translate (x1, y1, z1) to the origin2. Rotate (x’2, y’2, z’2) on to the z
axis3. Rotate the object around the z-axis4. Rotate the axis to the original
orientation
5. Translate the rotation axis to the
original position
(x2,y2,z2)
(x1,y1,z1)
x
z
y
R-1
T-1
R
T
( ) ( ) ( ) ( ) ( ) ( )TRRRRRTR abqbaq xyzyx111 ---=
BCET
sudipta.hit@gmail.com
General 3D Rotations
n Step 1. Translation
úúúú
û
ù
êêêê
ë
é
---
=
1000100010001
1
1
1
zyx
T
(x2,y2,z2)
(x1,y1,z1)
x
z
y
BCET
sudipta.hit@gmail.com
General 3D Rotations
n Step 2. Establish [ TR ]ax x axis
( )úúúú
û
ù
êêêê
ë
é-
=
úúúú
û
ù
êêêê
ë
é-
=
10000//00//00001
10000cossin00sincos00001
dcdbdbdc
x aaaa
aR
(a,b,c)(0,b,c)
ProjectedPoint a a
RotatedPoint
dc
cbc
db
cbb
=+
=a
=+
=a
22
22
cos
sin
x
y
z
BCET
sudipta.hit@gmail.com
Arbitrary Axis Rotation
n Step 3. Rotate about y axis by
(a,b,c)
(a,0,d)b
l
d
22
222222
cos,sin
cbd
dacballd
la
+=
+=++=
== bb
( )úúúú
û
ù
êêêê
ë
é -
=
úúúú
û
ù
êêêê
ë
é -
=
10000/0/00100/0/
10000cos0sin00100sin0cos
ldla
lald
y bb
bb
bRx
y
ProjectedPoint
zRotated
Point
b
BCET
sudipta.hit@gmail.com
Arbitrary Axis Rotation
n Step 4. Rotate about z axis by the desiredangle q
q
l
( )úúúú
û
ù
êêêê
ë
é -
=
1000010000cossin00sincos
qqqq
qzR
y
x
z
BCET
sudipta.hit@gmail.com
Arbitrary Axis Rotation
n Step 5. Apply the reverse transformation toplace the axis back in its initial position
x
y
l
l
z
( ) ( )
úúúú
û
ù
êêêê
ë
é
-
úúúú
û
ù
êêêê
ë
é
-úúúú
û
ù
êêêê
ë
é
---
=---
10000cos0sin00100sin0cos
10000cossin00sincos00001
1000100010001
1
1
1
111
bb
bb
aaaa
bazyx
yx RRT
( ) ( ) ( ) ( ) ( ) ( )TRRRRRTR abqbaq xyzyx111 ---=
BCET
sudipta.hit@gmail.com
Find the new coordinates of a unit cube 90º-rotatedabout an axis defined by its endpoints A(2,1,0) and
B(3,3,1).
Find the new coordinates of a unit cube 90º-rotatedabout an axis defined by its endpoints A(2,1,0) and
B(3,3,1).
A Unit Cube
Example
BCET
sudipta.hit@gmail.com
Example
n Step1. Translate point A to the origin
A’(0,0,0)x
z
y
B’(1,2,1)
úúúú
û
ù
êêêê
ë
é--
=
1000010010102001
T
BCET
sudipta.hit@gmail.com
xz
y
l
( )
úúúúúú
û
ù
êêêêêê
ë
é
-=
1000
055
5520
05
52550
0001
axR
6121
55
51cos
552
52
122sin
222
22
=++=
==a
==+
=a
lB’(1,2,1)
a
Projected point(0,2,1)
B”(1,0,Ö5)
Example
n Step 2. Rotate axis A’B’ about the x axis by andangle a, until it lies on the xz plane.
BCET
sudipta.hit@gmail.com
x
z
y
l
( )
úúúúúú
û
ù
êêêêêê
ë
é-
=
1000
06300
66
0010
0660
630
byR
630
65cos
66
61sin
==
==
b
b
b
B”(1,0, Ö 5)(0,0,Ö6)
Example
n Step 3. Rotate axis A’B’’ about the y axis by andangle , until it coincides with the z axis.b
BCET
sudipta.hit@gmail.com
Example
n Step 4. Rotate the cube 90° about the z axis
n Finally, the concatenated rotation matrix about thearbitrary axis AB becomes,
( ) ( ) ( ) ( ) ( ) ( )TRRRRRTR abbaq xyzyx °= --- 90111
( )úúúú
û
ù
êêêê
ë
é -
=°
1000010000010010
90zR
BCET
sudipta.hit@gmail.com
( )
úúúú
û
ù
êêêê
ë
é
--
-
=
úúúú
û
ù
êêêê
ë
é--
úúúúúú
û
ù
êêêêêê
ë
é
-
úúúúúú
û
ù
êêêêêê
ë
é-
úúúú
û
ù
êêêê
ë
é -
úúúúúú
û
ù
êêêêêê
ë
é
-úúúúúú
û
ù
êêêêêê
ë
é
-úúúú
û
ù
êêêê
ë
é
=
1000560.0167.0741.0650.0151.1075.0667.0742.0
742.1983.0075.0166.0
1000010010102001
1000
055
5520
05
52550
0001
1000
06300
66
0010
0660
630
1000010000010010
1000
06300
66
0010
0660
630
1000
055
5520
05
52550
0001
1000010010102001
qR
Example
BCET
sudipta.hit@gmail.com
[ ] ( ) [ ]PRP ×=¢ q
[ ]
úúúú
û
ù
êêêê
ë
é
-------
=
úúúú
û
ù
êêêê
ë
é
úúúú
û
ù
êêêê
ë
é
--
-
=¢
11111111076.0091.0560.0726.0817.0650.0301.1467.1483.0409.0151.1225.1184.0258.0484.0558.0
891.2909.1742.1725.2816.2834.1667.1650.2
11111111100110010000111111001100
1000560.0167.0741.0650.0151.1075.0667.0742.0
742.1983.0075.0166.0
P
Example
n Multiplying R(θ) by the point matrix of the original cube
BCET
sudipta.hit@gmail.com
Other Transformations
n Reflection Relative to the xy Plane
n Z-axis Shearxz
y
x
z
y
úúúú
û
ù
êêêê
ë
é
úúúú
û
ù
êêêê
ë
é
-=
úúúú
û
ù
êêêê
ë
é
11000010000100001
1zyx
zyx
'''
úúúú
û
ù
êêêê
ë
é
úúúú
û
ù
êêêê
ë
é
=
úúúú
û
ù
êêêê
ë
é
110000100010001
1'''
zyx
ba
zyx
BCET
sudipta.hit@gmail.com
Other Transformations
n Z-axis ShearThe effect of this transformation matrix is to alter x and y-coordinatevalues by an amount that is proportional to the z value, while leaving thez coordinate unchanged.
q Boundaries of planes that are perpendicular to the z axis are thus shiftedby an amount proportional to z.
q An example of the effect of this shearing matrix on a unit cube isshown in Fig., for shearing values a = b = 1. Shearing matrices forthe x axis and y axis are defined similarly.
úúúú
û
ù
êêêê
ë
é
úúúú
û
ù
êêêê
ë
é
=
úúúú
û
ù
êêêê
ë
é
110000100010001
1'''
zyx
ba
zyx
BCET
sudipta.hit@gmail.com
Coordinate Transformations
n Multiple Coordinate Systemn Local (modeling) coordinate systemn World coordinate scene
Local Coordinate System
BCET
sudipta.hit@gmail.com
Coordinate Transformations
n Multiple Coordinate Systemn Local (modeling) coordinate systemn World coordinate scene
Word Coordinate System
BCET
sudipta.hit@gmail.com
Coordinate Transformations
n Example – Simulation of Tractor movementn As tractor moves, tractor coordinate system and
front-wheel coordinate system move in worldcoordinate system
n Front wheels rotate in wheel coordinate system
BCET
sudipta.hit@gmail.com
Coordinate Transformations
n Transformation of an Object Description fromOne Coordinate System to Another
n Transformation Matrixn Bring the two coordinates systems into alignment1. Translation
x
y
z (0,0,0)
y’
z’
x’u'y
u'z
u'x(x0,y0,z0)x
y
z (0,0,0)
u'y
u'z
u'x
( )000 ,, zyx ---T
BCET
sudipta.hit@gmail.com
Coordinate Transformations
2. Rotation & Scaling
x
y
z (0,0,0)
y’
z’
x’u'y
u'z
u'x x
y
z (0,0,0) x
y
z (0,0,0)
úúúú
û
ù
êêêê
ë
é
¢¢¢¢¢¢¢¢¢
=
1000000
321
321
321
zzz
yyy
xxx
uuuuuuuuu
R