3D Geometric Transformation - TAUdcor/Graphics/cg-slides/geom3d.pdf · 3D Geometric Transformation...
Click here to load reader
Transcript of 3D Geometric Transformation - TAUdcor/Graphics/cg-slides/geom3d.pdf · 3D Geometric Transformation...
3D GeometricTransformation
(Chapt. 5 in FVD, Chapt. 11 in Hearn & Baker)
3D Coordinate Systems
• Right-handed coordinate system:
• Left-handed coordinate system:
y
z
x
x
y
z
Reminder: Vector Product
U
V
UxV
VxU
θsinˆ VUnVU =×
θ
−−−
==×
xyyx
zxxz
yzzy
zyx
zyx
vuvu
vuvu
vuvu
vvv
uuu
zyx
VU
ˆˆˆ
3D Point
• A 3D point P is represented inhomogeneous coordinates by a4-dim. vector:
• Note, that
=
1
z
y
x
P
≡
=
αααα
z
y
x
z
y
x
p
1
3D Transformations
• In homogeneous coordinates, 3Dtransformations are represented by4x4 matrices:
• A point transformation isperformed:
1000z
y
x
tihg
tfed
tcba
=
110001
'
'
'
z
y
x
tihg
tfed
tcba
z
y
x
z
y
x
3D Translation
• P in translated to P' by:
• Inverse translation:
+++
=
=
11
'
'
'
11000
100
010
001
z
y
x
z
y
x
tz
ty
tx
z
y
x
z
y
x
t
t
t
'PPT =Or
y
z
x
PPT =− '1
Scaling
=
=
11
'
'
'
11000
000
000
000
cz
by
ax
z
y
x
z
y
x
c
b
a
'PPS =Or
y
z
x
PPS =− '1
y
z
x
3D Shearing
• Shearing:
• The change in each coordinateis a linear combination of allthree.
• Transforms a cube into ageneral parallelepiped.
++++++
=
111000
01
01
01
zfyex
dzycx
bzayx
z
y
x
fe
dc
ba
3D Rotation
• To generate a rotation in 3D wehave to specify:– axis of rotation (2 d.o.f)
– amount of rotation (1 d.o.f)
• Note, the axis passes through theorigin.
x
y
z
• A counter-clockwise rotationabout the z-axis:
−
=
11000
0100
00cossin
00sincos
1
'
'
'
z
y
x
z
y
x
θθθθ
y
z
x
pRp z )(' θ=
• A counter-clockwise rotationabout the x-axis:
−
=
11000
0cossin0
0sincos0
0001
1
'
'
'
z
y
x
z
y
x
θθθθ
y
z
x
pRp x )(' θ=
• A counter-clockwise rotationabout the y-axis:
−=
11000
0cos0sin
0010
0sin0cos
1
'
'
'
z
y
x
z
y
x
θθ
θθ
y
z
x
pRp y )(' θ=
Inverse Rotation
')(')(1 pRpRp θθ −== −
Composite Rotations
• Rx, Ry, and Rz, can perform anyrotation about an axis passingthrough the origin.
Rotation About anArbitrary Axis
• Axis of rotation can be located atany point: 6 d.o.f.
• The idea: make the axiscoincident with one of thecoordinate axes (z axis), rotate,and then transform back.
• Assume that the axis passesthrough the point p0.
y
z
x
p0
• Transformations:– Translate P0 to the origin.
– Make the axis coincident with thez-axis (for example):
• Rotate about the x-axis into thexz plane.
• Rotate about the y-axis ontothe z-axis.
• Rotate as needed about the z-axis.
• Apply inverse rotations about yand x.
• Apply inverse translation.
y
zx
p0
y
x
p0
y
x
p0
y
x
p0
z
z
z
y
x
p0
z
y
zx
p0
A
B
C
D
E
F
3D Reflection
• A reflection through the xy plane:
• Reflections through the xz and theyz planes are defined similarly.
• How can we reflect through somearbitrary plane?
−=
−110000
0100
0010
0001
z
y
x
z
y
x
Transforming Planes
• Plane representation:– By three non-collinear points
– By implicit equation:
[ ] 0
1
=
=+++z
y
x
DCBADCzByAx
P0
P1P2
[ ]1zyx
1D
C
D
B
D
A
• One way to transform a plane isby transforming any three non-collinear points on the plane.
• Another way is to transform theplane equation: Given atransformation T thattransforms [x,y,z,1] to [x',y',z',1]find [A',B',C',D'], such that:
[ ] 0
1
'
'
'
'''' =
z
y
x
DCBA
• Note that
• Thus, the transformation thatwe should apply to the planeequation is:
[ ] 0
1
1 =
−
z
y
x
TTDCBA
( )
=
−
D
C
B
A
T
D
C
B
A
T1
'
'
'
'
Changing CoordinateSystems
• Problem: Given the XYZorthogonal coordinate system,find a transformation, M, thatmaps XYZ to an arbitraryorthogonal system UVW.
• This transformation changes arepresentation from the UVWsystem to the XYZ system.
y
z
x
u=(ux,uy,uz)
v=(vx,vy,vz)
w=(wx,wy,wz)
(x0,y0,z0)
• Solution: M=RT where T is atranslation matrix by (x0,y0,z0), andR is rotation matrix whose columnsare U,V, and W:
because
=
1000
0
0
0
zzz
yyy
xxx
wvu
wvu
wvu
R
Uu
u
u
wvu
wvu
wvu
RXz
y
x
zzz
yyy
xxx
=
=
=
11
0
0
1
1000
0
0
0
• Similarly, Y goes into V, and Zgoes into W.
• The inverse transform, T-1R-1,
provides the mapping fromUVW back to XYZ. For therotation matrix R-1=RT:
X
uuu
u
u
u
www
vvv
uuu
UR
zyx
z
y
x
zyx
zyx
zyx
T
=
=
++
=
=
1
0
0
1
1
0
0
11000
0
0
0
222
• Comment: Very useful if anarbitrary plane is to be mappedto the XY plane or vice versa.
• Possible to apply if an arbitraryvector is to be mapped to anaxis (How?).
Transformation Pipe-Line
ViewingTransformation
ModelingTransformation
WorkstationTransformation
ModelingCoordinates
World Coordinates
Viewing Coordinates
Device Coordinates
ProjectionTransformation
Projection Coordinates
Modeling CoordinateHierarchy
yw
zw
xw
world
TractorSystem
Front-WheelSystem
World
Tractor
Front-wheel
transformation
transformation