Presentation is loading. Please wait.

Presentation is loading. Please wait.

Rotation representation and Interpolation

Similar presentations


Presentation on theme: "Rotation representation and Interpolation"— Presentation transcript:

1 Rotation representation and Interpolation
CSE 3541 Matt Boggus

2 Rotation Matrices

3 Interpolating Orientations in 3D
Rotation matrices Given rotation matrices Mi and time ti, find M(t) such that M(ti)=Mi ux vx nx uy vy ny uz vz nz u v n

4 Flawed Solution Interpolate each entry independently
Example: M0 is identity and M1 is 90o around x-axis Is the result a rotation matrix?

5 Orientation Representations
Rotation matrix Fixed angles: rotate about global coordinate system Euler angles: rotate about local coordinate system Axis-angle: arbitrary axis and angle Quaternions: mathematically handy axis-angle 4-tuple

6 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)

7 Gimbal Lock Two or more axes align resulting in a loss of rotation degrees of freedom.

8 Fixed Angles in the Real World
Apollo inertial measurement unit To “prevent” lock, they added a fourth Gimbal

9 Axis-Angle Q Y A X Z Rotate about given axis Euler’s Rotation Theorem
Fairly easy to interpolate between orientations Difficult to concatenate rotations

10 Axis-angle to rotation matrix
Y Z Concatenate the following: Rotate A around z to x-z plane Rotate A’ around y to x-axis Rotate theta around x Undo rotation around y-axis Undo rotation around z-axis Q A

11 Quaternions (intuitionally)
X Y Z Q A Same as axis-angle, but different form Still rotate about given axis Mathematically convenient form Note: in this form v is a scaled version of the given axis of rotation, A (which is a vector)

12 Quaternion q = s + xi + yj + zk where i, j, and k are imaginary numbers 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)

13 Quaternion Arithmetic
Addition Multiplication Inner Product Length

14 Quaternion Arithmetic
Inverse Identity Unit quaternion

15 Quaternion Representation and Rotation
Vector Rotation

16 Unit Quaternion Conversions
Axis-Angle

17 What an animator needs to know
Quaternions What 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

18 Rotations within Unity
transform.Rotate(eulerAngles : Vector3, relativeTo : Space = Space.Self) Description Applies 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).

19 Rotations within Unity
transform.Rotate(axis : Vector3, angle : float, relativeTo : Space = Space.Self) Description Rotates the transform around axis by angle degrees.

20 Rotations within Unity
transform.RotateAround(point : Vector3, axis : Vector3, angle : float) Description Rotates the transform about axis passing through point in world coordinates by angle degrees. This modifies both the position and the rotation of the transform.

21 Rotations within Unity
Vector3.RotateTowards(current : Vector3, target : Vector3, maxRadiansDelta : float, maxMagnitudeDelta : float) Description Rotates a vector current towards target.

22 Orientation along a curve

23 Orientation on a curve in 2D

24 Orientation on a curve in 2D

25 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)

26 Frenet Frame Global axes: x, y, z Local axes: u, v, w
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 Global axes: x, y, z Local axes: u, v, w P(s) = parametric curve function with s on [0,1]

27 Frenet Frame tangent & curvature vector

28 Frenet Frame tangent & curvature vector

29 local coordinate system
Frenet Frame local 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

30 Frenet Frame – sometimes undefined

31 Frenet Frame – discontinuity

32 Other ways to control orientation
Use auxiliary curve to define direction or up vector Use point P(s+ds) for direction

33 Direction & Up vector To keep ‘head up’, use y-axis to compute over and up vectors perpendicular to direction vector v = u × w w If up vector supplied, use that instead of y-axis u=w × y-axis Direction vector

34 Orientation interpolation
Preliminary note: Remember that Affects of scale are divided out by the inverse appearing in quaternion rotation When interpolating quaternions, use UNIT quaternions – otherwise magnitudes can interfere with spacing of results of interpolation

35 Orientation interpolation
Quaternions can be interpolated to produce in-between orientations: 2 problems analogous to issues when interpolating positions: How to take equidistant steps along orientation path? How to pass through orientations smoothly (1st order continuous) And another particular to quaternions: with dual unit quaternion representations, which to use?

36 Dual representation Dual unit quaternion representations: q = –q
For Interpolation between q1 and q2, compute cosine between q1 and q2 and between q1 and –q2; choose smallest angle

37 Interpolating quaternions
Unit quaternions form set of points on 4D sphere Linearly interpolating unit quaternions: not equally spaced

38 Interpolating quaternions in great arc => equal spacing

39 Interpolating quaternions with equal spacing
where ‘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


Download ppt "Rotation representation and Interpolation"

Similar presentations


Ads by Google