rick parent - cis681 orientation use quaternions interpolating rotations is difficult

27
Rick Parent - CIS68 ORIENTATION Use Quaternions Interpolating rotations is difficult

Upload: colleen-henderson

Post on 12-Jan-2016

219 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

ORIENTATION

Use Quaternions

Interpolating rotations is difficult

Page 2: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Object Representation

Desired operationsInterpolation between transformationsConcatenation of one transformation after another

Define object in world spaceObject space data ScaleRotation Translation

Handle scale, rotation, translation, independently

Rotation deserves special attention!

Page 3: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Repeated Rotations: Error Management

Task: Rotate an object some every frame

Issue: Avoiding accumulated roundoff error

Page 4: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Repeated Rotations: Error Management

Method 2D = create_rotation_matrix()M create_rotation_matrix()M = D MObject = apply M to object

Method 1M = create_rotation_matrix()Object = apply M to Object

Method 3 = + M = create_rotation_matrix()Object = apply M to object

<= repeat

<= repeat

<= repeat

Page 5: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Orientation Representation

orientation

Page 6: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Interpolation

O1

O2

O 1.5

Page 7: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Concatenation

O1

O2

Page 8: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Orientation Representation

Rotation Matrix

Fixed Angles

Euler Angles

Axis-Angle

Quaternion

Page 9: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Rotation Matrices

0

0

0

1

a

d

g

b c

e f

h i

0 0 0

9 values but 3 degrees of freedom

Euler’s rotation theorem: An arbitrary rotation may be described by only three parameters.

Page 10: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Rotation Matrices

00

0

1

01

0

-1 00 0

0 1

0 0 0

000

1

0-10

1 00 00 1

0 0 0

Can’t interpolate rotation matrices

90o z-axis -90o z-axis0

0

0

1

0

0

0

0 0

0 0

0 1

0 0 0

??

Page 11: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Fixed Angles

E.g., (z, y, x)

XZ

Y

Q = Rx(x). Ry(y). Rz(z). P

Ordered triple of rotations about global axes, any triple can be used that doesn’t immediately repeat an axis, e.g., x-y-z, is fine, so is x-y-x. But x-x-z is not.

Page 12: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Fixed Angles

X

Z

Y

X

Z

Y

Note: left-hand coordinate system

Original orientationOrientation represented by

(0,90,0)

Using order z-y-x

Page 13: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Fixed Angles

(45,90,0)

X

Z

Y

X

Z

Y

Original

Using order z-y-x

Page 14: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Gimbal Lock

From (0,90,0), how can the object change its orientation?

X

Z

Y

a) (,90,0)

b) (,90+,0)

c) (,90,)

What do these do?

Using order z-y-x

Page 15: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Fixed Angles

(-45,90,0)(0,90,0)

X

Z

Y

Z

X

Y

Is same asX-axisrotation

(0,90,45)(0,90,0)

Changing Z-axis parameter

Page 16: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Fixed Angle Interpolation

(0,90,0) to (90,0,90)(0,0,0)

(90,0,90)(0,90,0)

Page 17: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Euler Angles

Ordered triple of rotations about local axes, As with fixed angles, any triple can be used that doesn’t immediately repeat an axis, e.g., x-y-z, is fine, so is x-y-x. But x-x-z is not.

X

Y

Z

x

y

z

Page 18: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Euler Angles

X

Y

Z

x

y

z

Use (z,y,x)

P Rz(1)P

P Rz(1)Ry (2)Rz ( 1) P

P Rz(1)Ry (2)Rz ( 1)Rz (1)P

P Rz(1)Ry (2)P

P Rz(1)Ry (2)Rx (3)Ry ( 2)Rz ( 1) P

P Rz(1)Ry (2)Rx (3)Ry ( 2)Rz ( 1)Rz (1)Ry (2)P

P Rz(1)Ry (2)Rx (3)P

Show that Euler angle ordering is equivalent to reverse ordering in fixed angles

…and so has the same problems

Page 19: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Axis-Angle

(Ax,Ay,Az,)

Euler’s rotation theorem: An arbitrary rotation may be described by only three parameters.

X

Y

Z

Rotate object by around A

?

Page 20: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Axis-Angle Interpolation

1. Interpolate axis from A1 to A2 Rotate axis about A1 x A2 to get A

X

Y

Z

2. Interpolate angle from 1 to to get

3. Rotate object by around A

A1 x A2

Page 21: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Quaternions

(cos(/2),sin(/2)*A)

q =[s,v]=[s,x,y,z]

Has the same information as axis-angle but in a more computational-friendly form

Page 22: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Quaternions

s1 v1 s2 v2 s1 s2 v1 v2 s1 v1 s2 v2 s1s2 v1 v2 s1v2 s2v1 v1 v2 q s2 x 2 y 2 z2

q 1 0 0 0 q

q 1 s v

q2

qq 1 1 0 0 0

Basic math operations

Page 23: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Quaternions - rotate a point

v = (x,y,z) => [0,v]

Rotq (v) v q 0 v q 1

Page 24: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Composite transformations

Rotq (Rotp (v)) Rotq ( p 0 v p 1)

qp 0 v p 1q 1

qp 0 v (qp) 1

Rotqp (v)

Rotation by p then by q is the same as rotation by qp(where qp is quaternion q multiplied by quaternion p)

Page 25: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Quaternion Rotation

q

||q||Unit quaternion =>

Rot s v Rotk s v Rot ks kv

Rot s v Rot s v

Page 26: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Quaternion Interpolation

Fixed angles

(90,0,90)(0,90,0)

quaternions

[0.7,0.0,0.7,0.0] [0.5,0.5,0.5,0.5]

Page 27: Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult

Rick Parent - CIS681

Quaternion Interpolation

Linearly interpolating fixed angles from (0,90,0) to

(90,0,90)

Interpolating quaternions from (0.5,0.0,1.0,0.0) to (0.5,0.5,0.5,0.5) using sphereical linear interpolation

QuickTime™ and aVideo decompressor

are needed to see this picture.

QuickTime™ and aVideo decompressor

are needed to see this picture.