Download presentation
Presentation is loading. Please wait.
1
UMBC Graphics for Games
Quaternion Rotation UMBC Graphics for Games
2
Representing Rotation
3
Rotation Matrices Rotation can be expressed as an orthogonal matrix
Every orthogonal matrix is a rotation and/or mirroring New X axis New Y axis New Z axis
4
Rotation Matrices Rotation can be expressed as an orthogonal matrix
Every orthogonal matrix is a rotation and/or mirroring Fits with other transformation matrices Translation, Scaling, Reflection, Perspective Interpolations between rotation matrices are not rotations Interpolates endpoint positions
5
Euler Angles Rotate around series of axes Subject to gimbal lock
Roll, Pitch, Yaw Intuitive, pitch/yaw form common for first person controllers Yaw = turn left/right Pitch = look up/down Roll = rotate around view Subject to gimbal lock First axis lines up with last axis, lose ability to rotate freely Interpolates along lines of longitude/latitude Can be weird near poles
6
Quaternions Extension of complex numbers
Interpolations on great circle Related Geometric Algebra also works Though not as popular in games
7
Complex Numbers
8
Imaginary number i Define imaginary number i where
Complex number has real and imaginary components Interpret as points on the 2D plane Conjugate: negate the imaginary part
9
Complex Arithmetic Addition: add components Multiplication
Component algebra: Multiply magnitudes, add angles:
10
Complex Transformations
Point Translation = addition Scale = multiply by real scalar Rotate = multiply by unit-length complex (magnitude = 1) Component form is identical to matrix rotation
11
Basic Rotations Pure imaginary = rotation by 90
12
Quaternions
13
Quaternion basics First created by Hamilton in 1843 for physics rotations Define orthogonal imaginary axes Multiplication order matters, positive in ijk order
14
Quaternion Math Like complex has real + imaginary, quaternion is real + vector Conjugate negates vector part Addition by component
15
Quaternion Multiplication
By component Vector form
16
Quaternion Transformations
Point is pure quaternion Translation = addition of pure quaternion Scale = multiply by real scalar Rotation = sandwiched multiply by unit quaternion and conjugate Where For one point, algebraically optimized version with cross products For more points, cheaper to convert to matrix
17
Basic Rotations Rotation Rotate by 0º Rotate by 180º around vector
18
Interpolation Interpolate along great circle between two vectors / quaternions Normalized Linear Interpolation (NLERP) Cheap, but speeds up in the middle Spherical Linear Interpolation (SLERP) Interpolate in equal-angular steps
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.