Professional Documents
Culture Documents
3-D Transformational Geometry: 6.1 Scale and Translation
3-D Transformational Geometry: 6.1 Scale and Translation
3-D Transformational
Geometry
We use the shorthand S(s) to denote a uniform scale matrix with scale
factor s.
37
38 c
2012 John C. Hart
y
+z (lhc)
x
+z (rhc)
x
y
y p=
z
1
x
y
v=
z
0
x
o = [0 0 0 1]T
v = (x, y, z) (6.6)
HOW TO ROTATE
ABOUT ANY UNIT VECTOR V
ABOUT AN y
Rv (θ) v = (x, y, z)
ARBITRARY AXIS
“THE ALGEBRAIC WAY” x
z
TX TY TZ 0
UX UY UZ 0
R=
VX VY VZ 0
0 0 0 1
R ROTATES T,U,V INTO X,Y,Z
R IS A ROTATION MATRIX
T.T T.U T.V
U.T U.U U.V
RT= = X, RU= = Y, RV= =Z
SINCE T,U,V ARE UNIT LENGTH... V.T V.U V.V
0 0 0
T.T = U.U = V.V = 1
Dot Product
The dot product on ordinary vectors is denoted a · b and is defined alge-
braically as
a · (b + c) = a · b + a · c, (6.10)
a a a
b
b
b
a·b>0 a·b=0 a·b<0
Figure 6.4: Signs of dot products.
where θ is the angle between a and b. From this definition, we can see
that if a and b are perpendicular, then a · b = 0 and the dot product
is positive when two non-orthogonal vectors point (even vaguely) in the
same direction and negative when pointing in opposite directions. This
definition is also useful to find the angle θ between two vectors a and b as
a b
cos θ = · . (6.13)
||a|| ||b||
c
2012 John C. Hart 43
θ
||
/||b
a·b
Figure 6.5: The dot product can be used to “cast a shadow” of vector a
perpendicularly onto vector b. The length a · b/||b|| is the component of
a in b’s direction.
As Fig. 6.5 shows, we can use the dot product to find the component
of a vector in the direction of another vector. In this example, the vector
a casts a shadow onto the vector b and this shadow is cast perpendicular
to b creating a right triangle. The hypotenuse is ||a||, so the adjacent
length is ||a|| cos θ, which when combined with the geometric definition of
the dot product (6.12), yields the length shown. The component of a in
b’s direction is commonly denoted ab and is elegantly defined
a·b
ab = b. (6.14)
b·b
Note that if ||b|| = 1, then a · b yields the portion of a in b’s direction.
Let x = [1 0 0 0]T , y = [0 1 0 0]T and z = [0 0 1 0]T . Then a = (a · x, a ·
y, a · z). In fact, one can find the coordinates of a in any coordinate system
this way, by redefining x, y and z.
Cross Product
The cross product is defined algebraically on ordinary 3-D vectors as
can be used to generate a homogeneous 4×4 matrix that generates the cross
product with a,
−az ay bx ay b z − az b y
az −ax
b y = az b x − ax b z . (6.18)
−ay ax bz ax by − ay bx
1 0 0
a × (b + c) = a × b + a × c, (6.19)
a × b = −b × a. (6.21)
When the cross product generates a vector of positive length, the vector
is perpendicular to the operand vectors,
(a × b) · a = (a × b) · b = 0. (6.22)
and will follow the right hand rule in the order of the operands
x × y = z, (6.23)
y × z = x, (6.24)
z × x = y. (6.25)
This is the most useful role for the cross product, to find a vector perpen-
dicular to the plane spanned by two other vectors.
The length of this vector is given by
Figure 6.6: The cross product of two vectors generates a new vector per-
pendicular to them both.
Gramm-Schmidt Orthonormalization
We can use the cross product to set up a new coordinate system, through a
method called Gramm-Schmidt orthonormalization. Given a unit vector v
in any direction, we will use the cross product to find two new unit vectors
t and u such that all three are mutually perpendicular and thus form
a right-handed “orthonormal” coordinate system ht, u, vi. Orthonormal
means
t·u=u·v =v·t = 0 (6.27)
||t|| = ||u|| = ||v|| = 1, (6.28)
and right-handed means
t × u = v, (6.29)
u × v = t, (6.30)
v × t = u. (6.31)
If v is not unit length, we first unitize it. Then we let
y×v
t= (6.32)
||y × v||
where y = (0, 1, 0). This will find a new direction for t perpendicular to
the plane containing v and the y axis. The vectors v and y might not
be perpendicular, so even though they are both unit length, their cross
product might not be. (Recall the magnitude of this cross product will
equal the sine of the angle between y and v.) Hence, we divide the cross
product by its magnitude to ensure the result is unit length
Since we know v 6= ±y, then t is a unit vector (somewhere in the
xz-plane). All that remains is to compute
u = v × t. (6.33)
(Since v and t are unit length and perpendicular, their cross product will
be unit length so we need not unitize the result.)
46 c
2012 John C. Hart
The second case occurs when v = −y, which similarly yields a null cross
product. In this case we assign the coordinate system
Hence a 90◦ rotation about the x axis should rotate a point on the y
axis to a point on the z axis. The transformation matrix that implements
a rotation by θ about the x axis is
1
cos θ − sin θ
R(θ, x) =
.
(6.38)
sin θ cos θ
1
but you can verify that R(90◦ , y)[0, 0, 1, 1]T = [1, 0, 0, 1]T . In this case, we
have rotated a point on the z axis back onto a point onto the x axis (since
nothing comes after z in alphabetical order).
Let R be a 4×4 rotation matrix and let Q be its upper-left 3×3 subma-
trix, the part that actually performs the 3-D rotation,
0
Q 0
R= 0 (6.42)
0 0 0 1
its rows are also orthogonal right-handed unit (row) vectors. If we focus
on the upper-left submatrix (the part of the homogeneous rotation matrix
that performs the rotation), we can decompose it into
u1
Q= u2 = v1 v2 v3
(6.43)
u3
where
||u1 || = ||u2 || = ||u3 || = 1, (6.44)
u1 · u2 = u2 · u3 = u3 · u1 = 0, (6.45)
u1 × u2 = u3 , u2 × u3 = u1 , u3 × u1 = u2 , (6.46)
and likewise for v1 , v2 and v3 .
A convenient property of these matrices is that the inverse of a special
orthogonal matrix is simply its transpose. Recall that for any invertible
matrix M we have M −1 M = I. For our 3×3 special orthogonal matrix Q,
we have that QT Q = I, because
v1
QT Q = v2
v1 v2 v3
v3
v 1 · v 1 v1 · v2 v1 · v3 1
= v 2 · v 1 v2 · v2 v2 · v3 = 1 , (6.47)
v 3 · v 1 v3 · v2 v3 · v3 1
Cayley’s Formula
Recall from the discussion of cross products that given a vector v =
(vx , vy , vz ), we can create a (skew-symmetric) matrix
−vz vy
"v = vz −vx (6.48)
−vy vx
GIVEN A UNIT VECTOR V, CREATE AN
HOW TO MAKE ORTHOGONAL COORDINATE SYSTEM <T,U,V>
AN ORTHOGONAL y
COORDINATE SYSTEM
v = (x, y, z)
“GRAMM SCHMIDT z
x
ORTHONORMALIZATION”
STEP 2: UNITIZE
YXV, TO CREATE
UNIT VECTOR T
whose product with a column vector yeilds the cross product of v with
that column vector.
Cayley’s formula uses these cross product matrices for v to create a
3×3 (non-homogeneous) rotation matrix about an arbitrary axis in the
direction of v
Q(θ, v) = (I + "v ) (I − "v )−1 (6.49)
by some angle θ. The vector v need not be unit length, and in fact its
length indicates the angle of rotation,
1−v·v
θ = arccos . (6.50)
1+v·v
where the rotation axis v is embedded in "v as shown in (6.48). Just hope
Q doesn’t represent a 180◦ rotation.
where R(φ) is some rotation that rotates the unit vector v into the z-axis.
Thus R(θ, v) rotates an object about the v axis by first rotating the object
onto the z-axis, then rotates the object around the z-axis, then rotates the
result back to the v axis. The trick is finding R(φ), the transformation
that rotates the v axis to the z axis. We have two ways. a geometric way
that is tedious but easy to follow, and an algebraic way that is simpler but
conceptually more difficult.
c
2012 John C. Hart 51
Figure 6.7: Rotation that takes v to the xz-plane also rotates its projection
vyz on the yz plane to the z-axis.
(0, y, z)
cos φx = z/d, (6.53)
sin φx = y/d, (6.54) y d
φx
z
yielding the homogeneous rotation matrix z
1
z/d −y/d
R(φx , x) =
.
(6.55)
y/d z/d
1
We will denote the result of this rotation v0xz = R(φx , x) v0 .
Next, we find a rotation about the y-axis R(φy , y) that rotates vxz from
the xz-plane into the z-axis. Note that vxz is a unit vector because it is a
52 c
2012 John C. Hart
cos φy = d, (6.56)
sin φy = −x, (6.57)
and
d −x
1
R(φy , y) =
.
(6.58)
x d
1
HOW TO ROTATE
THE DIRECTION OF THE AXIS
ABOUT AN y
Rv (θ) v = (x, y, z)
ARBITRARY AXIS
“THE GEOMETRIC WAY” x
z
y
TO FIND THE ANGLE, THEN USE TRIG
FIRST PROJECT V TO FIND (0, y, z) d= x2 + y 2
ONTO THE YZ PLANE THE ANGLE
cos φx = z/d
(0, y, z)
sin φx = y/d
v = (x, y, z) d
y
φx
Rx (φx ) x
z
φx Rx (φx )
z
x
1
z/d −y/d
z vxz Rx (φx ) =
y/d z/d
1
STEP 2: ROTATE VXZ ABOUT Y INTO THE Z AXIS, STEP 3: ROTATE BY THE ORIGINAL
y
ANGLE ABOUT THE Z AXIS
USE TRIG AGAIN TO y
FIND THE ANGLE
d
φy 1 x Rz (θ) x
x
z Ry (φy ) z
vxz
and furthermore RT u0 = y0 and RT v0 = z0 .
Hence we implement R(θ, v) using RT to rotate v to z, R(θ, z) to rotate
about z, and R to rotate the result back from z to v,