Rotation representation and Interpolation CSE 3541 Matt Boggus.
-
Upload
hugh-thompson -
Category
Documents
-
view
219 -
download
0
Transcript of Rotation representation and Interpolation CSE 3541 Matt Boggus.
Rotation representation and Interpolation
CSE 3541Matt Boggus
Rotation Matrices
1000
0100
00cossin
00sincos
1000
0cos0sin
0010
0sin0cos
1000
0cossin0
0sincos0
0001
Interpolating Orientations in 3D• Rotation matrices• Given rotation matrices Mi and time ti,
find M(t) such that M(ti)=Mi
x
y
z
M
uv
n
ux
vx
nx
uy
vy
ny
uz
vz
nz
Flawed Solution• Interpolate each entry independently• Example: M0 is identity and
M1 is 90o around x-axis
• Is the result a rotation matrix?
1 0 0 1 0 0 1 0 0
Interpolate ( 0 1 0 , 0 0 1 ) 0 0.5 0.5
0 0 1 0 1 0 0 0.5 0.5
1 0 0 1 0 0 1 0 0
Interpolate ( 0 1 0 , 0 0 1 ) 0 0.5 0.5
0 0 1 0 1 0 0 0.5 0.5
Orientation Representations
Rotation matrixFixed angles: rotate about global coordinate systemEuler angles: rotate about local coordinate systemAxis-angle: arbitrary axis and angleQuaternions: mathematically handy axis-angle 4-tuple
Fixed Angles
• Any orientation can be described by composing three rotations, one around each global coordinate axis
• Roll, pitch and yaw(perfect for flight simulation)
http://www.fho-emden.de/~hoffmann/gimbal09082002.pdf
Gimbal Lock• Two or more axes align resulting in a loss of
rotation degrees of freedom.
http://www.fho-emden.de/~hoffmann/gimbal09082002.pdf
Fixed Angles in the Real World
• Apollo inertial measurement unit• To “prevent” lock, they added a fourth Gimbal
http://www.hq.nasa.gov/office/pao/History/alsj/gimbals.html
Axis-Angle
zyx
A
Rotate about given axisEuler’s Rotation TheoremFairly easy to interpolate between orientationsDifficult to concatenate rotations
X
Y
Z
A Q
Axis-angle to rotation matrix
X
Y
Z
A Q Concatenate the following:Rotate A around z to x-z planeRotate A’ around y to x-axisRotate theta around xUndo rotation around y-axisUndo rotation around z-axis
Quaternions (intuitionally)
ARot A *)
2sin(
2cos
Same as axis-angle, but different formStill rotate about given axisMathematically convenient form
X
Y
Z
vs
qNote: in this form v is a scaled version of the given axis of rotation, A (which is a vector)
A Q
Quaternion
Rotation Quaternions
Identity (no rotation) 1, -1
180 degrees about x-axis i, -i
180 degrees about y-axis j, -j
180 degrees about z-axis k, -k
angle θ, axis (unit vector)
q = s + xi + yj + zk where i, j, and k are imaginary numbers
Quaternion Arithmetic
Addition
Multiplication
Length
Inner Product
22112121 vsvsvvss
212112212121 vvvsvsvvssqq
212121 vvssqq
qqq
Quaternion Arithmetic
Inverse vsqq
2
11
000111 qqqq
111 pqpq
Unit quaternionq
qq ˆ
Identity
Quaternion Representation and Rotation
Vector
Rotation
v0
1)(' qvqvRotv q
Unit Quaternion Conversions
22
22
22
2212222
2222122
2222221
yxsxyzsyxz
sxyzzxszxy
syxzszxyzy
Rot zyxs
vvzyx
s
/),,(
)(cos2 1
Axis-Angle
QuaternionsWhat an animator needs to know
Avoid gimbal lock
Easy to rotate a point
Easy to convert to a rotation matrix
Easy to concatenate – quaternion multiply
Easy to interpolate – interpolate 4-tuples
Rotations within Unity
transform.Rotate(eulerAngles : Vector3, relativeTo : Space = Space.Self)
DescriptionApplies a rotation of eulerAngles.z degrees around the z axis, eulerAngles.x degrees around the x axis, and eulerAngles.y degrees around the y axis (in that order).
Rotations within Unity
transform.Rotate(axis : Vector3, angle : float, relativeTo : Space = Space.Self)
DescriptionRotates the transform around axis by angle degrees.
Rotations within Unity
transform.RotateAround(point : Vector3, axis : Vector3, angle : float)
DescriptionRotates the transform about axis passing through point in world coordinates by angle degrees.This modifies both the position and the rotation of the transform.
Rotations within Unity
Vector3.RotateTowards(current : Vector3, target : Vector3, maxRadiansDelta : float, maxMagnitudeDelta : float)
DescriptionRotates a vector current towards target.
Orientation along a curve
Orientation on a curve in 2D
Orientation on a curve in 2D
Orientation on a curve in 2D
q1 and q2 are orthogonal to P’(u)i.e. q1 = Rotate(90) * P’(u) q2 = Rotate(-90) * P’(u)
Frenet Frame
Global axes: x, y, zLocal axes: u, v, wP(s) = parametric curve function with s on [0,1]
a moving (coordinate) frame that provides a coordinate system at each point of the curve that is "best adapted" to the curve near that point
Frenet Frame tangent & curvature vector
Frenet Frame tangent & curvature vector
MBUuP
MBUuP
UMBuP
'')(''
')('
)(
0026''
0123'
12
23
uU
uuU
uuuU
Frenet Framelocal coordinate system
Directly control orientation of object/camera
Use for direction and bank into turn, especially for ground-planar curves (e.g. roads)
w = P’(s)u = P’’(s) × P’(s)v = w × u
Frenet Frame – sometimes undefined
Frenet Frame – discontinuity
Other ways to control orientation
Use point P(s+ds) for direction
Use auxiliary curve to define direction or up vector
Direction & Up vector
Direction vector
w
u=w × y-axis
v = u × wTo keep ‘head up’, use y-axis to compute over and up vectors perpendicular to direction vector
If up vector supplied, use that instead of y-axis
Orientation interpolation
Preliminary note:1. Remember that2. Affects of scale are divided out by the inverse appearing in quaternion
rotation3. When interpolating quaternions, use UNIT quaternions – otherwise
magnitudes can interfere with spacing of results of interpolation
)()( vRotvRot kqq
Orientation interpolation
2 problems analogous to issues when interpolating positions:1. How to take equidistant steps along orientation path?2. How to pass through orientations smoothly (1st order continuous)3. And another particular to quaternions: with dual unit quaternion
representations, which to use?
Quaternions can be interpolated to produce in-between orientations:
21)1( kqqkq
Dual representation
Dual unit quaternion representations: q = –q
)()( vRotvRot kqq
For Interpolation between q1 and q2, compute cosine between q1 and q2 and between q1 and –q2; choose smallest angle
Interpolating quaternions
Linearly interpolating unit quaternions: not equally spaced
Unit quaternions form set of points on 4D sphere
Interpolating quaternions in great arc => equal spacing
Interpolating quaternions with equal spacing
2121 sin
sin
sin
)1sin(),,(slerp q
uq
uuqq
‘slerp’, sphereical linear interpolation is a function of • the beginning quaternion orientation, q1• the ending quaternion orientation, q2• the interpolant, u
Still a linear order interpolation
cos21 qqwhere