cse3431-lecture4.key
Rotation around an arbitrary axis
Euler’s theorem: Any rotation or sequence of
rotations around a point is equivalent to a single
rotation around an axis that passes through the
point.
What does the matrix look like?
Rotation around an arbitrary axis
through the origin
Axis: u
Point: P
Angle: β
Approach (one of many):
1. Two rotations to align u with
x-axis (arbitrary choice)
2. Do x-roll by β
3. Undo the alignment
Derivation
1. Rz(-φ)Ry(θ)
2. Rx(β)
3. Ry(-θ)Rz(φ)
Altogether:
Ry(-θ)Rz(φ) Rx(β) Rz(-φ)Ry(θ)
Derivation
1. Rz(-φ)Ry(θ)
2. Rx(β)
3. Ry(-θ)Rz(φ)
Altogether:
Ry(-θ)Rz(φ) Rx(β) Rz(-φ)Ry(θ)
Parameters:
Derivation
1. Rz(-φ)Ry(θ)
2. Rx(β)
3. Ry(-θ)Rz(φ)
Altogether:
Ry(-θ)Rz(φ) Rx(β) Rz(-φ)Ry(θ)
Exercise:
Derive the matrix for
rotation around an axis that
does not pass through the
origin
Properties of affine
transformations
1. Preservation of affine combinations of points.
2. Preservation of lines and planes.
3. Preservation of parallelism of lines and planes.
4. Relative ratios on a line are preserved.
5. Affine transformations are composed of
elementary ones.
Affine Combinations of Points
Line:
L(t) = (1� t)P1 + tP2
T (L(t)) = (1� t)T (P1) + tT (P2)
Plane
Pl(s, t) = (1� s� t)P1 + tP2 + sP3
T (Pl(s, t)) = (1� s� t)T (P1) + tT (P2) + sT (P3)
Proof: Direct consequence of previous property
Preservations of Lines and
Planes
Preservation of Parallelism for
Lines and Planes
Rigid body transformation
Combination of a translation and a
rotation
• Preserve lines, angles and distances
• 6 Degrees of freedom in 3D
General form of 3D affine
transformations
Rotation, Scaling,
Shear
Translation
0
BB
@
Qx
Qy
Qz
1
1
CC
A =
0
BB
@
m11 m12 m13 m14
m21 m22 m23 m24
m31 m32 m33 m34
0 0 0 1
1
CC
A
0
BB
@
Px
Py
Pz
1
1
CC
A
0
BB
@
wx
wy
wz
0
1
CC
A =
0
BB
@
m11 m12 m13 m14
m21 m22 m23 m24
m31 m32 m33 m34
0 0 0 1
1
CC
A
0
BB
@
vx
vy
vz
0
1
CC
A
Transforming Points and Vectors
• Points
• Vectors
Advanced concepts
Generalized shears
Decomposition of 2D AT:
2D : M = T Sh S R
3D: M = T S R Sh1 Sh2
Rotations in 3D
Gimbal lock
Quaternions
Exponential maps
Transformations of Coordinate
systems
Coordinate systems consist of vectors and
an origin (point), therefore we can
transform them just like any other group of
points and vectors
Alternative way to think of transformations:
• Transformations as a change of basis
Reminder: Coordinate systems
Coordinate
system: (a,b,c,θ)
Reminder: The homogeneous
representation of points and vectors
Transformation as a change of CS
xz
y
Pa
b
O
PA = (a, b, c, 1)A !
PA = ax+ by + cz+O
Assume a coordinate system A and a point P
Transformation as a change of CS
xz
y
Pa
b
O
Q
f
d
PA = (a, b, c, 1)A !
PA = ax+ by + cz+O
Transform with M
QA = MPA ! QA = (d, e, f, 1)A
A
Transformation as a change of CS
xz
y
Pa
b
O
Q
f
d
PA = (a, b, c, 1)A !
PA = ax+ by + cz+O
Transform with M
QA = MPA ! QA = (d, e, f, 1)A
Using the full form of PA
QA = MPA = M (axA + byA + czA +OA) !
Q = a(Mx) + b(My) + c(Mz) +MO
Transformation as a change of CS
xz
y
Pa
b
O
a b
Q
u
vw
G
f
d
PA = (a, b, c, 1)A !
PA = ax+ by + cz+O
Transform with M
QA = MPA ! QA = (d, e, f, 1)A
Using the full form of PA
QA = MPA = M (axA + byA + czA +OA) !
Q = a(Mx) + b(My) + c(Mz) +MO
We define coordinate system B :
u = Mx, v = My, w = Mz, G = MO
Which means:
Q = au+ bv + cw +G
Notice that by definition:
QB = (a, b, c, 1)B
Transformation as a change of CS
xz
y
Pa
b
O
Q
f
d
So interpretation one:
PA = (a, b, c, 1)A !
PA = ax+ by + cz+O
Transform with M
QA = MPA ! QA = (d, e, f, 1)A
Transformation as a change of CS
xz
y
Pa
b
O
a b
Q
u
vw
G
So interpretation two:
PA = (a, b, c, 1)A !
P = ax+ by + cz+O
Transform CS A with M into CS B
u = Mx, v = My, w = Mz, G = MO
The point maintains its coordinates but with respect to the new CS B
QB = (a, b, c, 1)B
In other words the point is fixed with respect to the moving CS
Transformation as a change of CS
a b
Q
u
vw
G
xz
y
Pa
b
O
So we have:
PA = (a, b, c, 1), QA = (d, e, f, 1),
QB = (a, b, c, 1), QA = MPA
Which means
QA = MPA ! QA = MQB
Let’s show explicitly the coordinates of each side of the matrix
QA = AMBQB
Remember, the same matrix transforms CS A into CS B, e.g.
uA = AMBxA
Transformation as a change of CS
a b
S
u
vw
G
xz
y
Pa
b
O
a
b
Q
CS A
CS B
CS C
Rk
i
j
Fixed point: Q = (a, b, c, 1)
We can repeat the process for system B and C ignoring A
CSC = T (CSB) : iB = BMCuB , jB = BMCuj etc
and
QB = BMCQC
Then chain them all together:
QA = AMBBMCQC
Chain of CS
a b
S
u
vw
G
xz
y
Pa
b
O
a
b
Q
CS A
CS B
CS C
Rk
i
j
Chain or hierarchy of CS (frames): A ! B ! C
Represented by the matrix relationships:
QB = BMCQC , QA = AMBQB , QA = AMBBMCQC
Chain can be reformulated
a b
S
u
vw
G
xz
y
Pa
b
O
a
b
Q
CS A
CS B
CS C
Rk
i
j
Chain or hierarchy of CS (frames): A ! B ! C
Represented by the matrix relationships:
QB = BMCQC , QA = AMBQB , QA = AMBBMCQC
Reformulate chain B ! A ! C
Represented by the matrix relationships:… ?
Chain can be reformulated
a b
S
u
vw
G
xz
y
Pa
b
O
a
b
Q
CS A
CS B
CS C
Rk
i
j
Chain or hierarchy of CS (frames): A ! B ! C
QB = BMCQC , QA = AMBQB , QA = AMBBMCQC
Reformulate chain B ! A ! C
QB = BMAQA, QA = AMCQC , QB = BMAAMCQC
remember: Non-trivial a�ne transformations can be inverted
BMA = (AMB)
�1,AMC = AMBBMC
Exercise
a b
S
u
vw
G
xz
y
Pa
b
O
a
b
Q
CS A
CS B
CS C
Rk
i
j
Chain: A ! B ! C
QB = BMCQC , QA = AMBQB , QA = AMBBMCQC
Chain B ! A ! C
QB = BMAQA, QA = AMCQC , QB = BMAAMCQC
BMA = (AMB)
�1,AMC = AMBBMC
What is CMA?
More details and derivations
Transforming CS1 into CS2
• Using an affine matrix M
x
y
j
i
j’
i’
O
O’
CS1
CS2
Transforming CS1 into CS2
• Using an affine matrix M
x
y
j
i
j’
i’
O
O’
CS1
CS2
Transform each element of the frame:
O
0
CS1 = T (OCS1) = T ((0, 0, 0, 1)) = M[0 0 0 1]
T
i0CS1 = T (iCS1) = T ((1, 0, 0, 0)) = M[1 0 0 0]
T
j0CS1 = T (jCS1) = T ((0, 1, 0, 0)) = M[0 1 0 0]
T
k0CS1 = T (kCS1) = T ((0, 0, 1, 0)) = M[0 0 1 0]
T
The following hold by definition:
O
0
CS2 = (0, 0, 0, 1)CS2, i
0
CS2 = (1, 0, 0, 0)CS1 · · ·
Also remember that:
iCS1 = (0, 0, 0, 0)CS1 means iCS1 = 1iCS1 + 0jCS1 + 0jKCS1 + 0OCS1
Transforming CS1 into CS2
• Using an affine matrix M
x
y
j
i
j’
i’
P
O
O’
a
b
e
d
CS1
CS2
Both systems are
equivalent.
There is nothing
special about CS1
Transform each element of the frame:
O
0
CS1 = T (OCS1) = T ((0, 0, 0, 1)) = M[0 0 0 1]
T
i0CS1 = T (iCS1) = T ((1, 0, 0, 0)) = M[1 0 0 0]
T
j0CS1 = T (jCS1) = T ((0, 1, 0, 0)) = M[0 1 0 0]
T
k0CS1 = T (kCS1) = T ((0, 0, 1, 0)) = M[0 0 1 0]
T
The following hold by definition:
O
0
CS2 = (0, 0, 0, 1), i
0
CS2 = (1, 0, 0, 0) · · ·
The following hold by definition for a point P in the space:
PCS1 = (a, b, c, 1)CS1 = aiCS1 + bjCS1 + ckCS1 +OCS1
PCS2 = (d, e, f, 1)CS2 = di
0
CS2 + ej
0
CS2 + fk
0
CS2 +O
0
CS2
PCS1 = (a, b, c, 1)CS1 = di
0
CS1 + ej
0
CS1 + fk
0
CS1 +O
0
CS1
PCS2 = (d, e, f, 1)CS2 = aiCS2 + bjCS2 + ckCS2 +OCS2
Transforming CS1 into CS2
• What is the relationship between P in CS2
and P in CS1 if CS2 = T(CS1) and T is an
affine transformation represented by matrix
M?
x
y
j
i
j’
i’
P
O
O’
a
b
e
d
CS1
CS2Notation and what we know:
PCS1 = (a, b, c, 1)
T
PCS2 = (d, e, f, 1)
T
O
0 = T (O), i0 = T (i), j0 = T (j), k0 = T (k)
Reminder:
O
0
CS2 = (0, 0, 0, 1), O
0
CS1 = T ((0, 0, 0, 1)) = M0
i0CS2 = (1, 0, 0, 0), i
0
CS1 = T ((1, 0, 0, 0))
In any frame P = di0 + ej0 + fk0 +O0 so in CS1 PCS1 = di
0
CS1 + ej
0
CS1 + fk
0
CS1 +O
0
CS1
We know that (i, j0,k0, O0) = T ((i, j,k, O))
All vectors below are in frame CS1 so for example i = (1, 0, 0, 0)
PCS1 = dT (i) + eT (j) + fT (k) + T (O) = d(Mi) + e(Mj) + f(Mk) +MO
= d(M
2
66
4
1
0
0
0
3
77
5) + e(M
2
66
4
0
1
0
0
3
77
5) + f(M
2
66
4
0
0
1
0
3
77
5) +M
2
66
4
0
0
0
1
3
77
5
= M
2
66
4
d
0
0
0
3
77
5+M
2
66
4
0
e
0
0
3
77
5+M
2
66
4
0
0
f
0
3
77
5+M
2
66
4
0
0
0
1
3
77
5
= M(
2
66
4
d
0
0
0
3
77
5+
2
66
4
0
e
0
0
3
77
5+
2
66
4
0
0
f
0
3
77
5+
2
66
4
0
0
0
1
3
77
5) = M
2
66
4
d
e
f
1
3
77
5
Derivation
P in CS1 vs P in CS2
x
y
j
i
j’
i’
P
O
O’
a
b
e
d
CS1
CS2
Successive transformations of
the Coordinate System
CS1 à CS2 à CS3
T1 T2
x
y
j
i
j’
i’
P
O
O’
T1 T2
CS1
CS2
CS3
Transformations as a change of
basis
Another way of approaching the issue of
relating two coordinate systems
Similar to the previous one but from a
different point of view
i
0
CS1 = (i
0
x, i
0
y, i
0
z)
j
0
CS1 = (j
0
x, j
0
y, j
0
z)
k
0
CS1 = (k
0
x, k
0
y, k
0
z)
O
0
CS1 = (O
0
x, O
0
y, O
0
z)
PCS1 = MPCS2
Transformations as a change of
basis CS2
CS1
We know the basis of CS2 with respect to CS1 i.e.:
Can we find the matrix M that transforms points from CS2 to CS1?
i’
j’ k’
P
x
z
y
Transformations as a change of
basis CS2
CS1
We know the basis vectors and we know that
What is M with respect to the basis vectors?
i’
j’ k’
P
x
z
y
Transformations as a change of
basis
• Note that this is actually the matrix that transforms
CS1 into CS2 with respect to CS1
• Sanity check:
MxCS1 =
2
66
4
i
0
x j
0
x k
0
x O
0
x
i
0
y j
0
y k
0
y O
0
y
i
0
z j
0
z k
0
z O
0
z
0 0 0 1
3
77
5
2
66
4
1
0
0
0
3
77
5 =
2
66
4
i
0
x
i
0
y
i
0
z
0
3
77
5 = i
0
CS1
Similarly
MyCS1 = j
0
CS1, MzCS1 = k
0
CS1, MOCS1 = O
0
CS1
Transformations as a change of
basis CS2
CS1
That is:
We can view transformations as a change of
coordinate system
i’
j’ k’
P
x
z
y
So really this matrix operation
has two interpretations
Mathematically equivalent
but conceptually different
•
PCS1 =
2
66
4
x
y
z
1
3
77
5 =
2
66
4
i
0
x j
0
x k
0
x O
0
x
i
0
y j
0
y k
0
y O
0
y
i
0
z j
0
z k
0
z O
0
z
0 0 0 1
3
77
5
2
66
4
a
b
c
1
3
77
5 = MPCS2
CS2
CS1
i’
j’ k’
P
x
z
y
A. Transformation in a single
coordinate system
Ignore CS2:
• Point (x,y,z,1) in CS1 is transformed
to point P’=(x’,y’,z’,1) in CS1 by a transfor-
mation represented by M
CS1
k’
P’
x
z
y
P
0
CS1 =
2
66
4
x
0
y
0
z
0
1
3
77
5 =
2
66
4
i
0
x j
0
x k
0
x O
0
x
i
0
y j
0
y k
0
y O
0
y
i
0
z j
0
z k
0
z O
0
z
0 0 0 1
3
77
5
2
66
4
x
y
z
1
3
77
5 = MPCS1
P
A. Transformation in a single
coordinate system
Ignore CS2:
• Point (x,y,z,1) in CS1 is transformed
to point P=(x’,y’,z’,1) in CS1 by a
transformation represented by M
• The transformation happens wrt to CS1
CS1
P
x
z
y
y
y’
P
0
CS1 =
2
66
4
x
0
y
0
z
0
1
3
77
5 =
2
66
4
i
0
x j
0
x k
0
x O
0
x
i
0
y j
0
y k
0
y O
0
y
i
0
z j
0
z k
0
z O
0
z
0 0 0 1
3
77
5
2
66
4
x
y
z
1
3
77
5 = MPCS1
B. Transformation of Coordinate
System (change of basis)
Interpretation two:
• CS1 is transformed to CS2 through a
transformation and the point remains fixed with
respect to CS2
PCS1 =
2
66
4
x
y
z
1
3
77
5 =
2
66
4
i
0
x j
0
x k
0
x O
0
x
i
0
y j
0
y k
0
y O
0
y
i
0
z j
0
z k
0
z O
0
z
0 0 0 1
3
77
5
2
66
4
a
b
c
1
3
77
5 = MPCS2
CS2
CS1
i’
j’
k’
P
x
z
y
b
B. Transformation of Coordinate
System (change of basis)
Interpretation two:
• CS1 is transformed to CS2 through a
transformation and the point remains fixed with
respect to CS2
PCS1 =
2
66
4
x
y
z
1
3
77
5 =
2
66
4
i
0
x j
0
x k
0
x O
0
x
i
0
y j
0
y k
0
y O
0
y
i
0
z j
0
z k
0
z O
0
z
0 0 0 1
3
77
5
2
66
4
a
b
c
1
3
77
5 = MPCS2
CS1
x
z
y
b
B. Transformation of Coordinate
System (change of basis)
Interpretation two:
• CS1 is transformed to CS2 through a
transformation and the point remains fixed with
respect to CS2
PCS1 =
2
66
4
x
y
z
1
3
77
5 =
2
66
4
i
0
x j
0
x k
0
x O
0
x
i
0
y j
0
y k
0
y O
0
y
i
0
z j
0
z k
0
z O
0
z
0 0 0 1
3
77
5
2
66
4
a
b
c
1
3
77
5 = MPCS2
CS1
x
z
y
b
CS2
i’
j’
k’
Transforming a point through
transforming coordinate systems
Transforming a point through
transforming coordinate systems
P M1P
Transforming a point through
transforming coordinate systems
P M1P M1M2P
Example
In 2D homogeneous coordinates
CS A
P = [1,1,1]T
P
Example
CS A
Transformation T(1,0): M
P’ = M[1,1,1]T = MP = [2,1,1]T
P’
Example
Equivalently
CS A
Transformation T(1,0): M on CSA
PA = AMBP
P = [1,1,1]T
P
CS B
Conceptual difference: the local
coordinates of P stay the same, the
local system changes and becomes
CSB.
In other words we transformed
system A and P along with it.
However the fixed coordinates of P
are now in CSB
Example
CS A
Transformation T(1,0): M on CSA
PA = AMBP
Next transformation?
P
CS B
Example
CS A
Two choices!
PA = AMBP
P
CS B
P
Example
CS A
After the last matrix T(1,0): BMC
This transformation now happens in
CSB
PA = AMBBMCP
CS B CS C
Hierarchy of systems
P
Example
CS A
We now have 3 systems we can work in
PA = AMBBMCP
CS B CS C
Hierarchy of systems
Example
CS A
Let’s rotate in CSB by R(z,45): After the matrix R(z,45) is inserted
PA = AMBBMCP PA = AMBB(R(z,45)B’B’MC)P P
CS
B
’
CS
C
CS B
Hierarchy of systems
P
CS A CS B CS C
Example
Same matrix here R(z,45): After the matrix R(z,45) is inserted
PA = AMBBMCP PA = AR(z,45)A’ A’MBMCP
Hierarchy of systems
P
CS A CS B CS C
P
CS A
CS
B
CS
C
CS
A’
Main point
Interpreting a transformation matrix
• PA = AMB PB
transforms a point within system A, from its current
location to a new one
• PA = AMB PB
transforms system A into B. Right of matrix M we talk
in B coordinates. Left of matrix M we talk in A
coordinates
Rule of thumb
Transforming a point P:
Transformations: T1,T2,T3
Matrix: M = M3 x M2 x M1
Point transformed by: MP
Successive transformations happen with respect to the same CS
Transforming a CS
Transformations: T1, T2, T3
Matrix: M = M1 x M2 x M3
A point has original coordinates MP
Each transformations happens with respect to the new CS
The last coordinate system (right most) represents the first transformation
applied to the point
Rule of thumb
To find the transformation matrix that
transforms P from CSB coordinates to CSA
coordinates, we find the sequence of
transformations that align CSA to CSB
accumulating matrices from left to right.
Explanation of this rule
CS A CS B
Transformation M: AMB
P
If we think transforming systems,
M takes CS A from the left and
produces B on the right.
AMB
After this transformation we talk
in B coordinates (right side).
If we think about points then we
move the other way. M takes B
on the right and produces the A
coordinates on the left:
AMB
Explanation of this rule
CS A CS B
Transformation M: AMB
P
Take this simple example where
to produce B we translate A by 1
on x axis.
PB = (1,1) PA = (2,1)
If we move A by +1 to transform
it into B then the coordinates of P
with respect to the new system
are shortened by 1 (B is closer to
P than A by 1). So if we want to
transform the coordinates of P
from B to A we need to add 1 in
x. Exactly what we need to do to
transform system A to B.