Graphics
3D Geometric
Transformation
고려대학교 그래픽스 연구실
cgvr.korea.ac.kr 1 Graphics Lab @ Korea University
Contents
CGVR
Translation
Scaling
Rotation
Other Transformations
Coordinate Transformations
cgvr.korea.ac.kr 2 Graphics Lab @ Korea University
Transformation in 3D
CGVR
Transformation Matrix
A D G J
B E H K 3 3 3 1
C F I L
0 0 0 S 1 3 1 1
33 : Scaling, Reflection, Shearing, Rotation
31 : Translation
11 : Uniform global Scaling
13 : Homogeneous representation
cgvr.korea.ac.kr 3 Graphics Lab @ Korea University
3D Translation
CGVR
Translation of a Point
x' x t x , y ' y t y , z ' z t z
x' 1 0 0 tx x
y ' 0 1 0
t y y
z ' 0 0 1 tz z
x 1 0 0 0 1 1
z
cgvr.korea.ac.kr 4 Graphics Lab @ Korea University
3D Scaling
CGVR
Uniform Scaling
x' x s x , y ' y s y , z ' z s z
x' s x 0 0 0 x
y ' 0 sy 0 0 y
z ' 0 0 sz 0 z
x
1 0 0 0 1 1
z
cgvr.korea.ac.kr 5 Graphics Lab @ Korea University
Relative Scaling
CGVR
Scaling with a Selected Fixed Position
y y y y
z x z x z x z x
Original position Translate Scaling Inverse Translate
x' 1 0 0 x f sx 0 0 0 1 0 0 x f x
y ' 0 1 0 y f 0 s y 0 0 0 1 0 y f y
T ( x f , y f , z f ) S ( s x , s y , s z ) T ( x f , y f , z f )
z ' 0 0 1 z f 0 0 sz 0 0 0 1 z f z
1 0 0 0 1 0 0 0 1 0 0 0 1 1
cgvr.korea.ac.kr 6 Graphics Lab @ Korea University
3D Rotation
CGVR
Coordinate-Axes Rotations
X-axis rotation
Y-axis rotation
Z-axis rotation
General 3D Rotations
Rotation about an axis that is parallel to one of the
coordinate axes
Rotation about an arbitrary axis
cgvr.korea.ac.kr 7 Graphics Lab @ Korea University
Coordinate-Axes Rotations
CGVR
Z-Axis
Z-AxisRotation
Rotation X-Axis
X-AxisRotation
Rotation Y-Axis
Y-AxisRotation
Rotation
x' cos sin 0 0 x x' 1 0 0 0 x x' cos 0 sin 0 x
y ' sin cos 0 0 y y ' 0 cos sin 0 y y ' 0 1 0 0 y
z' 0 0 1 0 z z ' 0 sin cos 0 z z ' sin 0 cos 0 z
1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1
y y y
x x x
z z z
cgvr.korea.ac.kr 8 Graphics Lab @ Korea University
Order of Rotations
CGVR
Order of Rotation Affects Final Position
X-axis Z-axis
Z-axis X-axis
cgvr.korea.ac.kr 9 Graphics Lab @ Korea University
General 3D Rotations
CGVR
Rotation about an Axis that is Parallel to One
of the Coordinate Axes
Translate the object so that the rotation axis
coincides with the parallel coordinate axis
Perform the specified rotation about that axis
Translate the object so that the rotation axis is
moved back to its original position
cgvr.korea.ac.kr 10 Graphics Lab @ Korea University
General 3D Rotations
CGVR
Rotation about an Arbitrary Axis
y Basic
BasicIdea
Idea
TT 1.1. Translate
Translate(x1,
(x1,y1,
y1,z1)
z1)totothe
theorigin
origin
(x2,y2,z2)
2.2. Rotate
Rotate(x’2,
(x’2,y’2,
y’2,z’2)
z’2)on
ontotothe
thezz
RR
axis
axis
(x1,y1,z1) 3.3. Rotate
Rotatethe
theobject
objectaround
aroundthe
thez-axis
z-axis
4.4. Rotate
Rotatethe
theaxis
axistotothe
theoriginal
original
x RR-1-1
orientation
orientation
z 5.5. Translate
Translatethe
therotation
rotationaxis
axistotothe
the
TT-1-1
original
originalposition
position
[TR ] ARB [TTR ]1[TR ]x [TR ]y [TR ]z [TR ]y [TR ]x [TTR ]
cgvr.korea.ac.kr 11 Graphics Lab @ Korea University
General 3D Rotations
CGVR
Step 1. Translation
y
(x2,y2,z2) 1 0 0 x1
0 1 0 y1
TTR
(x1,y1,z1) 0 0 1 z1
x
0 0 0 1
cgvr.korea.ac.kr 12 Graphics Lab @ Korea University
General 3D Rotations
CGVR
Step 2. Establish [ TR ]x x axis
y b b
sin
b2 c2 d
(0,b,c) c c
(a,b,c) cos
b2 c2 d
Projected
Point 1 0 0 0 1 0 0 0
0 cos sin 0 0 c / d b/d 0
x TR αx
0 sin cos 0 0 b / d
c/d 0
z
0 0 0 1 0 0 0 1
Rotated
Point
cgvr.korea.ac.kr 13 Graphics Lab @ Korea University
Arbitrary Axis Rotation
CGVR
Step 3. Rotate about y axis by
y a d
sin , cos
l l
l 2 a2 b2 c2 a 2 d 2
(a,b,c)
d b2 c2
Projected l
Point cos 0 sin 0 d / l 0 a / l 0
d 0 1 0 0 0 1 0 0
x TR y
sin 0 cos 0 a / l 0 d / l 0
(a,0,d)
0 0 0 1 0 0 0 1
Rotated
z Point
cgvr.korea.ac.kr 14 Graphics Lab @ Korea University
Arbitrary Axis Rotation
CGVR
Step 4. Rotate about z axis by the desired
angle
y
cos sin 0 0
sin cos 0 0
TR z
0 0 1 0
l
x
0 0 0 1
cgvr.korea.ac.kr 15 Graphics Lab @ Korea University
Arbitrary Axis Rotation
CGVR
Step 5. Apply the reverse transformation to
place the axis back in its initial position
y
1 0 0 x1 1 0 0 0
0 1 0 y1 0 cos sin 0
TTR 1TR x TR y
l 0 0 1 z1 0 sin cos 0
0 0 0 1 0 0 0 1
cos 0 sin 0
l 0 1 0 0
x
sin 0 cos 0
0 0 0 1
z
[TR ] ARB [TTR ]1[TR ]x [TR ]y [TR ]z [TR ]y [TR ]x [TTR ]
cgvr.korea.ac.kr 16 Graphics Lab @ Korea University
Example
CGVR
Ex) Find the new coordinates of a unit cube 90º-
rotated about an axis defined by its endpoints A(2,1,0)
and B(3,3,1).
A Unit Cube
cgvr.korea.ac.kr 17 Graphics Lab @ Korea University
Example
CGVR
Step1. Translate point A to the origin
y
1 0 0 2
B’(1,2,1)
0 1 0 1
[TTR ]
0 0 1 0
A’(0,0,0)
x 0 0 0 1
z
cgvr.korea.ac.kr 18 Graphics Lab @ Korea University
Example
CGVR
Step 2. Rotate axis A’B’ about the x axis by
and angle , until it lies on the xz plane.
2 2 2 5
sin
2 2 12 5 5
1 5
cos
y 5 5
Projected point
(0,2,1) B’(1,2,1)
l 12 2 2 12 6
l
1 0 0 0
x 5 2 5
0 0
z B”(1,0,5) TR αx 5 5
0 2 5 5
0
5 5
0 0 0 1
cgvr.korea.ac.kr 19 Graphics Lab @ Korea University
Example
CGVR
Step 3. Rotate axis A’B’’ about the y axis by
and angle , until it coincides with the z axis.
1 6
sin
y 6 6
5 30
cos
6 6
l 30 6
x 0 0
(0,0,6) 6 6
B”(1,0, 5) TR y 0 1 0 0
6 30
0 0
z 6 6
0 0 0 1
cgvr.korea.ac.kr 20 Graphics Lab @ Korea University
Example
CGVR
Step 4. Rotate the cube 90° about the z axis
0 1 0 0
1 0 0 0
TR 90z
0 0 1 0
0 0 0 1
Finally, the concatenated rotation matrix about the arbitrary
axis AB becomes,
[TR ] ARB [TTR ]1[TR ]x [TR ]y [TR ]90
z [TR ] y [TR ] x [TTR ]
cgvr.korea.ac.kr 21 Graphics Lab @ Korea University
Example
CGVR
1 0 0 0 30 6
1 0 0 2 5 2 5 0 0 0 1 0 0
0 6 6
1 0 1 0 5 5
0
0 1 0 0 0
[TR ] ARB 0 1 0
0 0 1 0 2 5 5 6 0 30 0 0 1 0
0 0 0
0 0 0 1 5 5 6 6 0 0
0 1
0 0 0 1 0 0 0 1
30 6 1 0 0 0
0 0 5 2 5 1 0 0 2
6 6 0 0
0 1 0
0
0 5 5 1 0 1
6 30 2 5 5 0 0 1 0
0 0 0 0
6 6 5 5 0 0 0 1
0 0 0 1 0 0 0 1
0.166 0.075 0.983 1.742
0.742 0.667 0.075 1 .151
0.650 0.741 0.167 0.560
0 0 0 1
cgvr.korea.ac.kr 22 Graphics Lab @ Korea University
Example
CGVR
Multiplying [TR]AB by the point matrix of the original
cube
P T P
*
R ARB
0.166 0.075 0.983 1.742 0 0 1 1 0 0 1 1
0.742 0.667 0.075 1.151 1 1 1 1 0 0 0 0
P
*
0.650 0.741 0.167 0.560 1 0 0 1 1 0 0 1
0 0 0 1 1 1 1 1 1 1 1 1
2.650 1.667 1.834 2.816 2.725 1.742 1.909 2.891
0.558 0.484 0.258 0.184 1.225 1.151 0.409 0.483
1.467 1.301 0.650 0.817 0.726 0.560 0.091 0.076
1 1 1 1 1 1 1 1
cgvr.korea.ac.kr 23 Graphics Lab @ Korea University
Other Transformations
CGVR
Reflection Relative to the xy Plane
x' 1 0 0 0 x
y y y' 0 1 0 0 y
z z ' 0 0 1 0 z
z x x 1 0 0 0 1 1
Z-axis Shear
x' 1 0 a 0 x
y ' 0 1 b 0 y
z ' 0 0 1 0 z
1 0 0 0 1 1
cgvr.korea.ac.kr 24 Graphics Lab @ Korea University
Coordinate Transformations
CGVR
Multiple Coordinate System
Hierarchical Modeling
World Coordinate
System
Tractor Coordinate
System
Front-Wheel
Coordinate System
As tractor moves, tractor coordinate system and front-wheel
coordinate system move in world coordinate system
front wheels rotate in wheel coordinate system
When tractor turns, wheel coordinate system rotates in tractor system
cgvr.korea.ac.kr 25 Graphics Lab @ Korea University
Coordinate Transformations
CGVR
Transformation of an Object Description from One
Coordinate System to Another
Set up a translation that brings the new coordinate origin to the
position of the other coordinate origin
Rotations that corresponding coordinate axes
Scaling transformation, if different scales are used in the two
coordinates systems
Example
y y’ ux1 ux 2 ux 3 0 1 0 0 x0
x’ u u u 0 0 1 0 y0
u’y R T y1 y 2 y 3
(x0,y0,z0) u’x uz1 uz 2 uz 3 0 0 0 1 z0
(0,0,0) x
z u’z 0 0 0 1 0 0 0 1
z’
cgvr.korea.ac.kr 26 Graphics Lab @ Korea University