Orientation - University of Western Australia · Representation of orientation • Homogeneous...
Transcript of Orientation - University of Western Australia · Representation of orientation • Homogeneous...
![Page 1: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/1.jpg)
3D orientation
![Page 2: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/2.jpg)
• Rotation matrix
• Fixed angle and Euler angle
• Axis angle
• Quaternion
• Exponential map
![Page 3: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/3.jpg)
Joints and rotationsRotational DOFs are widely used in character animation
3 translational DOFs
48 rotational DOFs
Each joint can have up to 3 DOFs
1 DOF: knee 2 DOF: wrist 3 DOF: arm
![Page 4: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/4.jpg)
Representation of orientation
• Homogeneous coordinates (review)
• 4X4 matrix used to represent translation, scaling, and rotation
• a point in the space is represented as
• Treat all transformations the same so that they can be easily combined
p =
⎡
⎢
⎢
⎣
x
y
z
1
⎤
⎥
⎥
⎦
![Page 5: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/5.jpg)
Translation
⎡
⎢
⎢
⎣
x + txy + tyz + tz
1
⎤
⎥
⎥
⎦
=
⎡
⎢
⎢
⎣
1 0 0 tx0 1 0 ty0 0 1 tz0 0 0 1
⎤
⎥
⎥
⎦
⎡
⎢
⎢
⎣
x
y
z
1
⎤
⎥
⎥
⎦
translationmatrixnew point old point
![Page 6: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/6.jpg)
Scaling
⎡
⎢
⎢
⎣
sxx
syy
szz
1
⎤
⎥
⎥
⎦
=
⎡
⎢
⎢
⎣
sx 0 0 0
0 sy 0 0
0 0 sz 0
0 0 0 1
⎤
⎥
⎥
⎦
⎡
⎢
⎢
⎣
x
y
z
1
⎤
⎥
⎥
⎦
scaling matrixnew point old point
![Page 7: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/7.jpg)
Rotation
⎡
⎢
⎢
⎣
x′
y′
z′
1
⎤
⎥
⎥
⎦
=
⎡
⎢
⎢
⎣
cos θ − sin θ 0 0
sin θ cos θ 0 0
0 0 1 0
0 0 0 1
⎤
⎥
⎥
⎦
⎡
⎢
⎢
⎣
xyz1
⎤
⎥
⎥
⎦
⎡
⎢
⎢
⎣
x′
y′
z′
1
⎤
⎥
⎥
⎦
=
⎡
⎢
⎢
⎣
1 0 0 0
0 cos θ − sin θ 0
0 sin θ cos θ 0
0 0 0 1
⎤
⎥
⎥
⎦
⎡
⎢
⎢
⎣
xyz1
⎤
⎥
⎥
⎦
⎡
⎢
⎢
⎣
x′
y′
z′
1
⎤
⎥
⎥
⎦
=
⎡
⎢
⎢
⎣
cos θ 0 sin θ 0
0 1 0 0
− sin θ 0 cos θ 0
0 0 0 1
⎤
⎥
⎥
⎦
⎡
⎢
⎢
⎣
xyz1
⎤
⎥
⎥
⎦
X axis
Y axis
Z axis
![Page 8: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/8.jpg)
Quiz
• True or False: Given an arbitrary rotation matrix R
• R is always orthonormal
• R is always symmetric
• RRT = I
• Rx(30)Ry(60) = Ry(60)Rx(30)
![Page 9: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/9.jpg)
Interpolation
• In order to “move things”, we need both translation and rotation
• Interpolation the translation is easy, but what about rotations?
![Page 10: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/10.jpg)
Interpolation of orientation
• How about interpolating each entry of the rotation matrix?
• The interpolated matrix might no longer be orthonormal, leading to nonsense for the in-between rotations
![Page 11: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/11.jpg)
Interpolation of orientationExample: interpolate linearly from a positive 90 degree rotation about y axis to a negative 90 degree rotation about y
⎡
⎢
⎢
⎣
0 0 1 0
0 1 0 0
−1 0 0 0
0 0 0 1
⎤
⎥
⎥
⎦
⎡
⎢
⎢
⎣
0 0 −1 0
0 1 0 0
1 0 0 0
0 0 0 1
⎤
⎥
⎥
⎦
⎡
⎢
⎢
⎣
0 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
⎤
⎥
⎥
⎦
Linearly interpolate each component and halfway between, you get this...
![Page 12: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/12.jpg)
Properties of rotation matrix
• Easily composed? Yes
• Interpolate? No
![Page 13: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/13.jpg)
• Rotation matrix
• Fixed angle and Euler angle
• Axis angle
• Quaternion
• Exponential map
![Page 14: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/14.jpg)
Fixed angle
• Angles used to rotate about fixed axes
• Orientations are specified by a set of 3 ordered parameters that represent 3 ordered rotations about fixed axes
• Many possible orderings
![Page 15: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/15.jpg)
Euler angle
• Same as fixed angles, except now the axes move with the object
• An Euler angle is a rotation about a single Cartesian axis
• Create multi-DOF rotations by concatenating Euler angles
• evaluate each axis independently in a set order
![Page 16: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/16.jpg)
Euler angle vs. fixed angle• Rz(90)Ry(60)Rx(30) = Ex(30)Ey(60)Ez(90)
• Euler angle rotations about moving axes written in reverse order are the same as the fixed axis rotations
Z
Y
X
![Page 17: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/17.jpg)
Properties of Euler angle
• Easily composed? No
• Interpolate? Sometimes
• How about joint limit? Easy
• What seems to be the problem? Gimbal lock
![Page 18: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/18.jpg)
Gimbal Lock
A Gimbal is a hardware implementation of Euler angles used for mounting gyroscopes or expensive globes
Gimbal lock is a basic problem with representing 3D rotation using Euler angles or fixed angles
![Page 19: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/19.jpg)
Gimbal lockWhen two rotational axis of an object pointing in the same direction, the rotation ends up losing one degree of freedom
![Page 20: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/20.jpg)
• Rotation matrix
• Fixed angle and Euler angle
• Axis angle
• Quaternion
• Exponential map
![Page 21: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/21.jpg)
Axis angle
• Represent orientation as a vector and a scalar
• vector is the axis to rotate about
• scalar is the angle to rotate by
x
y
z
![Page 22: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/22.jpg)
Properties of axis angle
• Can avoid Gimbal lock. Why?
• It does 3D orientation in one step
• Can interpolate the vector and the scalar separately. How?
![Page 23: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/23.jpg)
Axis angle interpolation
B = A1 × A2
φ = cos−1
!
A1 · A2
|A1||A2|
"
Ak = RB(kφ)A1
θk = (1 − k)θ1 + kθ2
x
y
z
A2
θ2
A1θ1
![Page 24: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/24.jpg)
Properties of axis angle
• Easily composed? No, must convert back to matrix form
• Interpolate? Yes
• Joint limit? Yes
• Avoid Gimbal lock? Yes
![Page 25: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/25.jpg)
• Rotation matrix
• Fixed angle and Euler angle
• Axis angle
• Quaternion
• Exponential map
![Page 26: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/26.jpg)
Quaternion: geometric view
θ2
θ1
1-angle rotation can be represented by a unit circle
(θ1,φ1)
(θ2,φ2)
2-angle rotation can be represented by a unit sphere
What about 3-angle rotation?
A unit quaternion is a point on the 4D sphere
![Page 27: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/27.jpg)
Quaternion: algebraic view4 tuple of real numbers: w, x, y, z
q =
⎡
⎢
⎢
⎣
w
x
y
z
⎤
⎥
⎥
⎦
=
[
w
v
]
scalarvector
r
θq =
!
cos (θ/2)sin (θ/2)r
"
Same information as axis angles but in a different form
![Page 28: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/28.jpg)
Basic quaternion definitions
• Unit quaternion
• Inverse quaternion
• Identity
|q| = 1
x2
+ y2
+ z2
+ w2
= 1
q−1
=
q∗
|q|
qq−1
=
⎡
⎢
⎢
⎣
1
0
0
0
⎤
⎥
⎥
⎦
Conjugate q∗
=
!
w
v
"
∗
=
!
w
−v
"
![Page 29: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/29.jpg)
Quaternion multiplication
• Commutativity
• Associativity
!
w1
v1
" !
w2
v2
"
=
!
w1w2 − v1 · v2
w1v2 + w2v1 + v1 × v2
"
q1q2 ̸= q2q1
q1(q2q3) = (q1q2)q3
![Page 30: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/30.jpg)
Quaternion Rotation
qp =
!
0
p
"
q =
!
cos (θ/2)sin (θ/2)r
"
If is a unit quaternion andq
then results in rotating about by qqpq−1
r θp
proof: see Quaternions by Shoemaker
p
x
y
z
θ
r
![Page 31: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/31.jpg)
Quaternion Rotationqqpq
−1=
!
w
v
" !
0
p
" !
w
−v
"
=
!
w
v
" !
p · v
wp − p × v
"
= 0=
!
wp · v − v · wp + v · p × v
w(wp − p × v) + (p · v)v + v × (wp − p × v)
"
!
w1
v1
" !
w2
v2
"
=
!
w1w2 − v1 · v2
w1v2 + w2v1 + v1 × v2
"
![Page 32: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/32.jpg)
Quaternion composition
If and are unit quaternionq2q1
q3 = q2 · q1
the combined rotation of first rotating by and then by is equivalent to
q1
q2
![Page 33: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/33.jpg)
Matrix form
q =
⎡
⎢
⎢
⎣
w
x
y
z
⎤
⎥
⎥
⎦
R(q) =
⎡
⎢
⎢
⎣
1 − 2y2− 2z
2 2xy + 2wz 2xz − 2wy 02xy − 2wz 1 − 2x
2− 2z
2 2yz + 2wx 02xz + 2wy 2yz − 2wx 1 − 2x
2− 2y
2 00 0 0 1
⎤
⎥
⎥
⎦
![Page 34: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/34.jpg)
Quaternion interpolation
• Interpolation means moving on n-D sphere
θ2
θ1
1-angle rotation can be represented by a unit circle
(θ1,φ1)
(θ2,φ2)
2-angle rotation can be represented by a unit sphere
![Page 35: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/35.jpg)
Quaternion interpolation
• Moving between two points on the 4D unit sphere
• a unit quaternion at each step - another point on the 4D unit sphere
• move with constant angular velocity along the great circle between the two points on the 4D unit sphere
![Page 36: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/36.jpg)
Quaternion interpolation
Direct linear interpolation does not work
Spherical linear interpolation (SLERP)
slerp(q1,q2, u) = q1
sin((1 − u)θ)
sin θ+ q2
sin(uθ)
sin θ
Normalize to regain unit quaternion
Linearly interpolated intermediate points are not uniformly spaced when projected onto the circle
θ
![Page 37: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/37.jpg)
Quaternion constraints
Cone constraint
θ
1 − cos θ
2= y2
+ z2q =
⎡
⎢
⎢
⎣
w
x
y
z
⎤
⎥
⎥
⎦
tan (θ/2) =qaxis
w
θ
Twist constraint
qaxis is the element of twist axis, e.g. z-axis
e.g. a cone along-x axis
![Page 38: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/38.jpg)
Properties of quaternion
• Easily composed?
• Interpolate?
• Joint limit?
• Avoid Gimbal lock?
• So what’s bad about Quaternion?
![Page 39: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/39.jpg)
• Rotation matrix
• Fixed angle and Euler angle
• Axis angle
• Quaternion
• Exponential map
![Page 40: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/40.jpg)
Exponential map
• Represent orientation as a vector
• direction of the vector is the axis to rotate about
• magnitude of the vector is the angle to rotate by
• Zero vector represents the identity rotation
![Page 41: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/41.jpg)
Properties of exponential map
• No need to re-normalize the parameters
• Fewer DOFs
• Good interpolation behavior
• Singularities exist but can be avoided
![Page 42: Orientation - University of Western Australia · Representation of orientation • Homogeneous coordinates (review) • 4X4 matrix used to represent translation, scaling, and rotation](https://reader033.fdocuments.net/reader033/viewer/2022060301/5f0855d27e708231d4218027/html5/thumbnails/42.jpg)
Choose a representation• Choose the best representation for the task
• common animation input:
• joint limits:
• interpolation:
• composition:
• avoid gimbal lock:
• rendering:
axis angle, quaternion
Euler angles
orientation matrix
quaternion or orientation matrix
Euler angles, axis angle, quaternion (harder)
axis and angle, quaternion