CSCE 441 Lecture 37

From Notes
Jump to navigation Jump to search

« previous | Wednesday, April 23, 2014 | next »


Quaternions and Complex Numbers

how they should be used.


Complex Numbers

Defined by a real and imaginary part:

, where .

Simple operations:

  • Conjugation: becomes . What's impressive about this is that , where

Relation to Graphics

Given a point , rotate that point about the origin by :


Represent by a complex number:


Rotation is just multiplication by a complex number.


Quaternions

Sir William Rowan Hamilton attempted to extend complex numbers from 2D to 3D, but this is now provably impossible. He discovered a generalization to 4D and wrote it on the side of a bridge in Dublin.

One real part, 3 complex parts:

From this, we get


We can define an algebra on

and

  • Multiplication:
    • Order matters in quaternion multiplication!
  • Conjugation: , and
  • Inversion:


Relation to Graphics

Claim: unit quaternions represent 3D rotation

Convert from 3D to 4D: , where .


Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle q = \left( \cos{\theta}, \sin{\theta} \, \vec{v} \right)} , where .

let Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \vec{v}} be parallel to the axis of rotation in 3D.

In this case, Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle p \, q = q \, p = \left( -\sin{\theta}, \cos{\theta} \, \vec{v} \right)} . This gives a nonzero real component... uh oh, we now have a 4D number, not a 3D number.

let Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \vec{v}^\perp} be a vector component in the plane normal to Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \vec{r}} :

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle q\,p} represents a positive (ccw) rotation, and Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle p \, q} represents a negative (cw) rotation.


Computing Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle q \, p \, \bar{q}} rotates the component of Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \vec{v}} perpendicular to Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle r} by Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle 2 \theta} and leaves the parallel component alone.

Thus the quaternion representing rotation about the unit axis Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \vec{v}} by Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \theta} is
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle q \, (0, \vec{r}) \, \bar{q}} , where Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle q = \left( \cos{ \left( \frac{\theta}{2} \right) }, \sin{ \left( \frac{\theta}{2} \right) } \vec{v} \right)}


Quaternions vs. Matrices

This seems like magic... This is perhaps the wrong use for quaternions

  • Quaternions take less space (4 vs. 9)
  • Rotating a vector requires 28 multiplications using quaternions vs. 9 for matrices
  • Composing two rotations using quaternions Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle q_1 \, q_2} requires 16 multiplications vs. 27 for matrices
  • Quaternions are not hardware-accelerated whereas matrices are.

Quaternions and Interpolation

Unit quaternions represent points on a 4D hypersphere

Interpolation on the sphere gives rotations that bend the least.

Recall we used SLERP to interpolate vectors on the surface of a 3D sphere.


May need to interpolate between Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle q_1} and Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle -q_2} .

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle q(t) = \frac{ \sin{ \left( \theta \, (1-t) \right)} \, q_1 + \sin{(\theta \, t)} q_2}{\sin{\theta}}} , where Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \cos^{-1}{ \left( q_1 \cdot q_2 \right)} = \theta} .

Other Graphics Uses for Quaternions

Skeletal animation: moving bones usually requires a lot of composed rotations.