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/5541 Matt Boggus

2 Overview Options for controlling orientation for Lab4
Interpolating between orientations

3 Orientation on a curve in 2D

4 Orientation on a curve in 2D

5 Orientation on a curve in 2D
q1 and q2 are orthogonal to P’(s) i.e. q1 = Rotate(90) * P’(s) q2 = Rotate(-90) * P’(s)

6 Example using physical object
In 3D Example using physical object

7 Orientation on a curve in 3D – Frenet Frame
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]

8 Rotation around an arbitrary angle
X 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

9 Interpolating between orientations
u v w

10 Interpolating Orientations in 3D
Rotation matrices Given rotation matrices Mi and time ti, find M(t) such that M(ti)=Mi ux vx wx uy vy wy uz vz wz u v w

11 Rotation Matrices

12 Flawed solution: Interpolate matrix elements
Example: M0 is identity and M1 is 90o around x-axis

13 Another flawed solution: Interpolating between angle values

14 Discovering another problem with Euler (a.k.a. Fixed) Angle rotation
Any orientation can be described by composing three rotations, one around each coordinate axis Each rotation corresponds to rotating one of the frames

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

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

17 Quaternion representation
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)

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

19 Quaternion Arithmetic
Addition Multiplication Inner Product Length

20 Quaternion Arithmetic
Inverse Identity Unit quaternion

21 Quaternion Representation and Rotation
Vector Rotation

22 Converting between representations
Axis-Angle

23 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

24 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

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

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

27 Interpolating quaternions in great arc => equal spacing

28 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

29 Additional slides

30 More on Frenet frame and 3D orientation setting

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

32 Frenet Frame tangent & curvature vector

33 Frenet Frame tangent & curvature vector

34 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

35 Frenet Frame – sometimes undefined

36 Frenet Frame – discontinuity

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

38 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

39 More on Quaternions For a good example on the web, see

40 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

41 Related methods in Unity

42 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).

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

44 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.

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

46 GameObject Transform fields
Try explicitly setting: transform.forward transform.up transform.right

47 Quaternion methods


Download ppt "Rotation representation and Interpolation"

Similar presentations


Ads by Google