07.01.2013 Views

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Quaternions and spatial rotation 136<br />

Performance comparisons with other rotation methods<br />

This section discusses the performance implications of using quaternions versus other methods (axis/angle or<br />

rotation matrices) to perform rotations in <strong>3D</strong>.<br />

Results<br />

Storage requirements<br />

Method Storage<br />

Rotation matrix 9<br />

Quaternion 4<br />

Angle/axis 3*<br />

* Note: angle-axis can be stored as 3 elements by multiplying the unit rotation axis by the rotation angle, forming the<br />

logarithm of the quaternion, at the cost of additional calculations.<br />

Used methods<br />

Performance comparison of rotation chaining operations<br />

Method # multiplies # add/subtracts total operations<br />

Rotation matrices 27 18 45<br />

Quaternions 16 12 28<br />

Performance comparison of vector rotating operations<br />

Method # multiplies # add/subtracts # sin/cos total operations<br />

Rotation matrix 9 6 0 15<br />

Quaternions 18 12 0 30<br />

Angle/axis 23 16 2 41<br />

There are three basic approaches to rotating a vector :<br />

1. Compute the matrix product of a 3x3 rotation matrix R and the original 3x1 column matrix representing . This<br />

requires 3*(3 multiplications + 2 additions) = 9 multiplications and 6 additions, the most efficient method for<br />

rotating a vector.<br />

2. Using the quaternion-vector rotation formula derived above of , the rotated vector can be<br />

evaluated directly via two quaternion products from the definition. However, the number of multiply/add<br />

operations can be minimised by expanding both quaternion products of into vector operations by twice<br />

applying . Further applying a number of<br />

vector identities yields which requires only 18 multiplies and 12 additions<br />

to evaluate. As a second approach, the quaternion could first be converted to its equivalent angle/axis<br />

representation then the angle/axis representation used to rotate the vector. However, this is both less efficient and<br />

less numerically stable when the quaternion nears the no-rotation point.<br />

3. Use the angle-axis formula to convert an angle/axis to a rotation matrix R then multiplying with a vector.<br />

Converting the angle/axis to R using common subexpression elimination costs 14 multiplies, 2 function calls (sin,<br />

cos), and 10 add/subtracts; from item 1, rotating using R adds an additional 9 multiplications and 6 additions for a<br />

total of 23 multiplies, 16 add/subtracts, and 2 function calls (sin, cos).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!