You are on page 1of 5

3D Geometrical Transformations 3D Geometrical Transformations

Foley & Van Dam, Chapter 5


• 3D point representation
• Translation
• Scaling, reflection
• Shearing
• Rotations about x, y and z axis
• Composition of rotations
• Rotation about an arbitrary axis
• Transforming planes

3D Coordinate Systems Reminder: Cross Product


UxV

Right-handed coordinate system:


z V

T
U

y VxU
x
Left-handed coordinate system: U u V nˆ U V sin T
y
xˆ yˆ zˆ ªu y v z  u z v y º
« »
U u V u x u y u z « u z v x  u x v z »
v x v y v z
« u x v y  u y v x
»
z ¬ ¼
x

3D Point Representation 3D Geometrical Transformations


• A 3D point P is represented in homogeneous • In homogeneous coordinates, 3D affine
coordinates by a 4-dimensional vector: transformations are represented by 4x4 matrices:
ª x º ª a b c t ºx
« y »» « »
P « « d e f ty »
« z »
« » « g h i tz »
¬ 1 ¼ « »
¬ 0 0 0 1 ¼
•As for 2D points: •A point transformation is performed:
ª x º ªD x º
« y » « » ª x 'º ª a b c t º ª x º
» { «D y
x
p « » « « »
« z » «D z » « y ' »» « d e f ty »
«
« y »
»
« » « » « z '» « g h i tz » « z »
¬ 1 ¼ ¬ D ¼ « » « » « »
¬ 1 ¼ ¬ 0 0 0 1 ¼ ¬ 1 ¼
3D Translation 3D Scaling
ª a 0 0 0 º ª x º ª x 'º ª ax º
P in translated to P' by: «
« 0 b 0 0 »» «
« y »» «
« y ' »» «
« by »
»
ª1 0 0 t ºx ª x º ª x 'º ª x  t x º « 0 0 c 0 » « z » « z '» « cz »
«0 » « » « « » « » « » « »
« 1 0 t »y « y » « y ' »» « y  t
« y
»
» ¬ 0 0 0 1 ¼ ¬ 1 ¼ ¬ 1 ¼ ¬ 1 ¼
«0 0 1 tz » « z » « z '» « z  t z »
« » « » « » « »
¬0 0 0 1 ¼ ¬ 1 ¼ ¬ 1 ¼ ¬ 1 ¼
Or S P P '

Or: T P P ' z z z

y y y
x x x
 1
Inverse: T  1
P ' P S P ' P

3D Reflection 3D Shearing
• A reflection through the xy plane: • Shearing:
ª1 a b 0 º ª x º ª x  ay  bz º
«c 1 d 0 »» « y »» « cx  y  dz »
ª1 0 0 0 º ª º x ª x º « « « »
«e f 1 0 » « z » « ex  fy  z »
«0 1 0 0 » « » y « y »» « » « » « »
« » « » « ¬0 0 0 1 ¼ ¬ 1 ¼ ¬ 1 ¼
«0 0 1 0 » « » z «  z »
« » « » « » • Change in each coordinate is a linear combination of
¬0 0 0 1 ¼ ¬ 1 ¼ ¬ 1 ¼
all three
• Transforms a cube into a general parallelepiped
•Reflections through the xz and the yz planes are
defined similarly

3D Rotation 3D Rotation
• To generate a rotation in 3D we have to • Counterclockwise rotation about x-axis
specify: ª
«
x 'º ª1 0 0 0 º ª x º
y ' »» «0 cos T  sin T 0 » « y »
– axis of rotation (2 d.o.f.) «
« z '»
«
«0 sin T cos T 0
»
»
«
« z
»
»
« » « » « »
– amount of rotation (1 d.o.f.) ¬ 1 ¼ ¬0 0 0 1 ¼ ¬ 1 ¼

•Note, the axis passes through the origin p ' R (T ) p


x
y
z

z y
x x
3D Rotation 3D Rotation
• Counterclockwise rotation about y-axis • Counterclockwise rotation about z-axis
ª x 'º ª cos T 0  sin T 0 º ª x º ª x 'º ª cos ș  sin ș 0 0 º ª x º
« y ' »» « 0 1 0 0 » « y » « y '» « sin ș cos ș 0 0 » « y »
« « » « » 0 0 1 0
« z '» « sin T 0 cos T 0 » « z »
« z '» « » « z »
« » « » « » «¬ 1 »¼ «¬ 0 0 0 1 »¼ «¬ 1 »¼
¬ 1 ¼ ¬ 0 0 0 1 ¼ ¬ 1 ¼
p ' R z (T ) p
p ' R y (T ) p
z
z

y y
x x

Composite Rotation Change of Coordinates


• Rx, Ry, and Rz, can perform any rotation • Problem: Given the XYZ orthonormal coordinate
about an axis passing through the origin system, find a transformation M, that maps a
representation in XYZ into a representation in the
orthonormal system UVW, with the same origin
•Inverse rotation: •The matrix M transforms the UVW vectors to the
XYZ vectors z
p R  1 (T ) p ' R ( T ) p ' R T (T )
u=(ux,uy,uz)
y
x
v=(vx,vy,vz)

Change of Coordinates Change of Coordinates


• Solution: M is rotation matrix whose rows • Let's check the transformation of U under M:
are U,V, and W: ª u x u y u z 0 º ªu x º
ª u x u y u z 0 º « v x v y v z 0 » «u y »
« MU « » « »
« vx v y vz 0 »» « w x w y w z 0 » «u z »
M
« w x w y w z 0 » «¬ 0 0 0 1 »¼ «¬ 1 »¼
« »
¬ 0 0 0 1 ¼
2
ªu  u 2y  u 2 º ª1
• Note: the inverse transformation is the «
x z
» «0
º
»
0 X
transpose: «
« 0
»
»
«0 »
ªu x v x w 0 º ¬ 1 ¼ «¬ 1 »¼
x
1 T
«u y v y w y 0 »
M M « » • Similarly, V goes into Y, and W goes into Z
«u z v z w z 0 »
¬« 0 0 0 1 ¼»
Change of Coordinates Rotation About an Arbitrary Axis
• Let's check the transformation of the X axis • Axis of rotation can be located at any point:
under M-1: 6 d.o.f. (we must specify 2 points p1 and p2)
ª1 º ªu x v x w x 0 º ª1 º ªu x º • The idea: make the axis coincident with
«0 «u y v y w 0 » «0 «u y »
M 1
«0
»
«
y
» «0
»
« » U one of the coordinate axes (z axis), rotate by
«u z v z w 0 «u z
» z
»
» »
¬« 1 ¼» ¬« 1 ¼»
¬« 0 0 0 1 ¼» ¬« 1 ¼» T, and then transform back
z
p2
p1
• Similarly, Y goes into V, and Z goes into W

y
x

Rotation About an Arbitrary Axis Rotation About an Arbitrary Axis


§ 1 0 0  x ·
y
step 3 y
1

• Step1: T
¨
¨ 0 1 0  y 1
¸
¸
p1 p2 p2 p1
¨
¨
0
0
0
0
1
0
 z
1
1 ¸
¸
© ¹
x x
z Initial Position z § u x
¨
u y u z 0 ·
¸
Rotate the Object • Step 2: M ¨ v x v y v z 0 ¸
Around the z Axis ¨ w x w y w z 0 ¸
y y ¨ 0
© 0 0 1 ¸
¹
p1 step 4 p1
step 1 p2 p2 § cos ș sin ș 0 0 ·
• Step 3: R
¨  sin ș cos ș 0 0 ¸
x x ¨ 0 0 1 0 ¸
zTranslate p z Rotate the Axis to the ¨
© 0 0 0 1 ¸
¹
1 to the Origin § u x v x w 0 ·
original Orientation ¨ u y v y w
x
0 ¸
• Step 4: M 1 ¨
u z v z w
y
0
¸
¨ z ¸
y y
¨
© 0 0 0 1 ¸
¹

step 2 p1 step 5 p1 p2 §
¨
1 0 0 x 1 ·
¸
0 1 0 y 1
• Step 5: T 1
¨ ¸
x x
¨ 0 0 1 z1 ¸
z p2
¨ 0 0 0 1 ¸
z Translate to the
©
 1  1
¹
Rotate p2 onto the z Axis
Original Position
• Composition: P c T M R M T P

Rotation About Arbitrary Axis Transforming Planes


• Constructing an orthonormal system along the
rotation axis: • Plane representation:
– A vector W parallel to the rotation axis: – By three non-collinear points
s – By implicit equation: x º
s p 2  p 1; w ª
s « y »»
A x  B y  C z  D >A B C D @ « 0
– A vector V perpendicular to W: « z »
« »
§ 0 · ªA B C º ¬ 1 ¼
¨ ¸ a 1»
a w u ¨ 0 ¸ ; v «D D D
¬ ¼
¨ 1 ¸ a
© ¹
P1
– A vector U forming a right-handed orthogonal system P2
with W and V:
u v u w >x y z 1@
P0
Transforming Planes Transforming Planes
• One way to transform a plane is by transforming • Note that: ª x º
any three non-collinear points on the plane « »
y
>A B C D @ T  1T « » 0
« z »
• Another way is to transform the plane equation: « »
Given a transformation T such that ¬ 1 ¼
T [x, y, z, 1] = [x', y', z', 1] • Thus, the transformation that we should
find [A',B',C',D'], such that: apply to the plane equation is:
ª x 'º
« y ' »»
>A ' B ' C ' D '@ « 0 > Ac Bc C c D c@ >A B C D @ T 1
« z '»
« »
¬ 1 ¼

You might also like