transformation 3d
Post on 13-Dec-2014
6.825 Views
Preview:
DESCRIPTION
TRANSCRIPT
Graphics
Graphics Lab @ Korea University
3D Geometric Transformation
고려대학교 컴퓨터 그래픽스 연구실
CGVR
Graphics Lab @ Korea University
Contents
Translation
Scaling
Rotation
Rotations with Quaternions
Other Transformations
Coordinate Transformations
CGVR
Graphics Lab @ Korea University
Transformation in 3D
Transformation Matrix
1131
1333
000 S
LIFC
KHEB
JGDA
33 : Scaling, Reflection, Shearing, Rotation33 : Scaling, Reflection, Shearing, Rotation
31 : Translation31 : Translation
13 : Homogeneous representation13 : Homogeneous representation
11 : Uniform global Scaling11 : Uniform global Scaling
CGVR
Graphics Lab @ Korea University
3D Translation
Translation of a Point
zyx tzztyytxx ',',' zyx tzztyytxx ',','
11000
100
010
001
1
'
'
'
z
y
x
t
t
t
z
y
x
z
y
x
xz
y
CGVR
Graphics Lab @ Korea University
3D Scaling
Uniform Scaling
zyx szzsyysxx ',',' zyx szzsyysxx ',','
11000
000
000
000
1
'
'
'
z
y
x
s
s
s
z
y
x
z
y
x
xz
y
CGVR
Graphics Lab @ Korea University
Relative Scaling
Scaling with a Selected Fixed Position
11000
100
010
001
1000
000
000
000
1000
100
010
001
1
'
'
'
),,(),,(),,(z
y
x
z
y
x
s
s
s
z
y
x
z
y
x
zyxTsssSzyxTf
f
f
z
y
x
f
f
f
fffzyxfff
x x x xzzzz
y y y y
Original position Translate Scaling Inverse Translate
CGVR
Graphics Lab @ Korea University
3D Rotation
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
Graphics Lab @ Korea University
Coordinate-Axes Rotations
Z-Axis Rotation X-Axis Rotation Y-Axis Rotation
11000
0100
00cossin
00sincos
1
'
'
'
z
y
x
z
y
x
z
y
x
11000
0cossin0
0sincos0
0001
1
'
'
'
z
y
x
z
y
x
11000
0cos0sin
0010
0sin0cos
1
'
'
'
z
y
x
z
y
x
z
y
xz
y
x
CGVR
Graphics Lab @ Korea University
Order of Rotations
Order of Rotation Affects Final Position X-axis Z-axis
Z-axis X-axis
CGVR
Graphics Lab @ Korea University
General 3D Rotations
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
Graphics Lab @ Korea University
General 3D Rotations
Rotation about an Arbitrary Axis
Basic Idea
1. Translate (x1, y1, z1) to the origin
2. Rotate (x’2, y’2, z’2) on to the z
axis
3. Rotate the object around the z-axis
4. Rotate the axis to the original
orientation
5. Translate the rotation axis to the
original position
Basic Idea
1. Translate (x1, y1, z1) to the origin
2. Rotate (x’2, y’2, z’2) on to the z
axis
3. Rotate the object around the z-axis
4. 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-1R-1
T-1T-1
RR
TT
TRRRRRTR xyzyx111
CGVR
Graphics Lab @ Korea University
General 3D Rotations
Step 1. Translation
1000
100
010
001
1
1
1
z
y
x
T
(x2,y2,z2)
(x1,y1,z1)
x
z
y
CGVR
Graphics Lab @ Korea University
General 3D Rotations
Step 2. Establish [ TR ]x x axis
1000
0//0
0//0
0001
1000
0cossin0
0sincos0
0001
dcdb
dbdcx
R
(a,b,c)(0,b,c)
Projected Point
Rotated Point
d
c
cb
c
d
b
cb
b
22
22
cos
sin
x
y
z
CGVR
Graphics Lab @ Korea University
Arbitrary Axis Rotation
Step 3. Rotate about y axis by
(a,b,c)
(a,0,d)
l
d
22
222222
cos,sin
cbd
dacbal
l
d
l
a
1000
0/0/
0010
0/0/
1000
0cos0sin
0010
0sin0cos
ldla
lald
y
Rx
y
Projected Point
zRotated
Point
CGVR
Graphics Lab @ Korea University
Arbitrary Axis Rotation
Step 4. Rotate about z axis by the desired angle
l
1000
0100
00cossin
00sincos
zR
y
x
z
CGVR
Graphics Lab @ Korea University
Arbitrary Axis Rotation
Step 5. Apply the reverse transformation to place the axis back in its initial position
x
y
l
l
z
1000
0cos0sin
0010
0sin0cos
1000
0cossin0
0sincos0
0001
1000
100
010
001
1
1
1
111
z
y
x
yx RRT
TRRRRRTR xyzyx111
CGVR
Graphics Lab @ Korea University
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).
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
Example
CGVR
Graphics Lab @ Korea University
Example
Step1. Translate point A to the origin
A’(0,0,0)x
z
y
B’(1,2,1)
1000
0100
1010
2001
T
CGVR
Graphics Lab @ Korea University
x
z
y
l
1000
05
5
5
520
05
52
5
50
0001
xR
6121
5
5
5
1cos
5
52
5
2
12
2sin
222
22
lB’(1,2,1)
Projected point (0,2,1)
B”(1,0,5)
Example
Step 2. Rotate axis A’B’ about the x axis by and angle , until it lies on the xz plane.
CGVR
Graphics Lab @ Korea University
x
z
y
l
1000
06
300
6
60010
06
60
6
30
yR
6
30
6
5cos
6
6
6
1sin
B”(1,0, 5)(0,0,6)
Example
Step 3. Rotate axis A’B’’ about the y axis by and angle , until it coincides with the z axis.
CGVR
Graphics Lab @ Korea University
Example
Step 4. Rotate the cube 90° about the z axis
Finally, the concatenated rotation matrix about the arbitrary axis AB becomes,
TRRRRRTR xyzyx 90111
1000
0100
0001
0010
90zR
CGVR
Graphics Lab @ Korea University
1000
560.0167.0741.0650.0
151.1075.0667.0742.0
742.1983.0075.0166.0
1000
0100
1010
2001
1000
05
5
5
520
05
52
5
50
0001
1000
06
300
6
60010
06
60
6
30
1000
0100
0001
0010
1000
06
300
6
60010
06
60
6
30
1000
05
5
5
520
05
52
5
50
0001
1000
0100
1010
2001
R
Example
CGVR
Graphics Lab @ Korea University
PRP
11111111
076.0091.0560.0726.0817.0650.0301.1467.1
483.0409.0151.1225.1184.0258.0484.0558.0
891.2909.1742.1725.2816.2834.1667.1650.2
11111111
10011001
00001111
11001100
1000
560.0167.0741.0650.0
151.1075.0667.0742.0
742.1983.0075.0166.0
P
Example
Multiplying R(θ) by the point matrix of the original cube
CGVR
Graphics Lab @ Korea University
Rotations with Quaternions
Quaternion Scalar part s + vector part v = (a, b, c) Real part + complex part (imaginary numbers i, j, k)
Rotation about any axis Set up a unit quaternion (u: unit vector)
Represent any point position P in quaternion notation (p = (x, y, z))
2sin ,
2cos
uv s
pP ,0
ckbjaissq v ,
CGVR
Graphics Lab @ Korea University
Rotations with Quaternions
Carry out with the quaternion operation (q-1=(s, –v))
Produce the new quaternion
Obtain the rotation matrix by quaternion multiplication
Include the translations:
1 qqPP
pP ,0
pvvpvvpvpp ss 22
22
22
22
11
2212222
2222122
2222221
basabcsbac
sabccascab
sbacscabcb
xyzyxR RRRRRM
TMTR R1
CGVR
Graphics Lab @ Korea University
Example
Rotation about z axis Set the unit quaternion: Substitute a=b=0, c=sin(θ/2) into the matrix:
2
sin1 ,0 ,0 ,2
cos
vs
100
0cossin
0sincos
100
02
sin212
sin2
cos2
02
sin2
cos22
sin21
2
2
RM
sin2
sin2
cos2
cos2
sin21 2
CGVR
Graphics Lab @ Korea University
Other Transformations
Reflection Relative to the xy Plane
Z-axis Shear
xz
y
x
z
y
11000
0100
0010
0001
1
z
y
x
z
y
x
'
'
'
11000
0100
010
001
1
'
'
'
z
y
x
b
a
z
y
x
CGVR
Graphics Lab @ Korea University
Coordinate Transformations
Multiple Coordinate System Local (modeling) coordinate system World coordinate scene
Local Coordinate System
CGVR
Graphics Lab @ Korea University
Coordinate Transformations
Multiple Coordinate System Local (modeling) coordinate system World coordinate scene
Word Coordinate System
CGVR
Graphics Lab @ Korea University
Coordinate Transformations
Example – Simulation of Tractor movement As tractor moves, tractor coordinate system and
front-wheel coordinate system move in world coordinate system
Front wheels rotate in wheel coordinate system
CGVR
Graphics Lab @ Korea University
Coordinate Transformations
Transformation of an Object Description from One Coordinate System to Another
Transformation Matrix Bring the two coordinates systems into alignment
1. 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
CGVR
Graphics Lab @ Korea University
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)
u'y
u'z
u'x x
y
z (0,0,0)
u'y
u'z
u'x
1000
0
0
0
321
321
321
zzz
yyy
xxx
uuu
uuu
uuu
R
top related