|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.proteinshader.math.QuaternionDemo
public class QuaternionDemo
Performs several tests on the Quaternion class, including a test
of the SLERP (Spherical Linear intERPolation) algorithm.
TEST A - Matrix to Quaternion Conversion
TEST B - Quaternion to Matrix Conversion
TEST C - Multiply a Point by a Quaternion
TEST D - Interpolation between 2 Quaternions
Some of the SLERP tests are based on figures and examples of
quaternion interpolation (SLERP) on the "EuclideanSpace - building
a 3D world" web site by Martin Baker:
http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
(cited December 2006).
Field Summary | |
---|---|
static int |
BANNER_WIDTH
The banner width is the number of asterisks to print on the line line above or below a banner title. |
Constructor Summary | |
---|---|
QuaternionDemo()
Creates a QuaternionDemo object with several vector and quaternions that can be used for testing purposes. |
Method Summary | |
---|---|
void |
convertToQuaternionAndPrint(Vec3d N,
Vec3d B,
Vec3d T)
Converts rotation matrix [N B T] to a quaternion and prints it. |
String |
createRepeats(char ch,
int n)
Returns a String with the character given as an argument repeated n number of times. |
static void |
main(String[] args)
Creates a QuaternionDemo object and uses it to test several operations on class Quaternion. |
void |
printBanner(String title,
String message)
Prints a banner with a row of asterisks above and below the title, and then a message right below the banner. |
void |
printColumnVectors(Vec3d N,
Vec3d B,
Vec3d T)
Prints the 3 column vectors to standard out. |
void |
printInterpolation(Quaternion start,
Quaternion end,
double[] t)
For each value in the array t, the slerp() method of class Quaternion will be used to calculate and print an interpolated Quaternion between the start and end Quaternions. |
void |
testMatrixToQuaternionConversion()
TEST A: Creates two matrices with known quaternion solutions and prints the matrices, the known solutions, and the solutions generated by class Quaternion. |
void |
testMultiplyPointByQuaternion()
TEST C: Prints the results of several Point3d x Quaternion multiplications. |
void |
testQuaternionToMatrixConversion()
TEST B: Prints the result of converting a Matrix to a Quaternion and then converting the Quaternion back to a Matrix. |
void |
testSlerp()
TEST D: Tests the SLERP (Spherical Linear intERPolation) algorithm of class Quaternion. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BANNER_WIDTH
Constructor Detail |
---|
public QuaternionDemo()
Method Detail |
---|
public void testMatrixToQuaternionConversion()
public void testQuaternionToMatrixConversion()
public void testMultiplyPointByQuaternion()
public void testSlerp()
1. identity quaternion = (0.000, 0.000, 0.000, 1.000)
2. +90 degree x-roll = (0.707, 0.000, 0.000, 0.707)
3. -90 degree x-roll = (-0.707, 0.000, 0.000, 0.707)
4. +90 degree y-roll = (0.000, 0.707, 0.000, 0.707)
5. -90 degree y-roll = (0.000, -0.707, 0.000, 0.707)
6. +90 degree z-roll = (0.000, 0.000, 0.707, 0.707)
7. -90 degree z-roll = (0.000, 0.000, -0.707, 0.707)
public void printInterpolation(Quaternion start, Quaternion end, double[] t)
start
- the start quaternion for the interpolation.end
- the end quaternion for the interpolation.t
- a parameter between 0.0 and 1.0, inclusive.public void printBanner(String title, String message)
title
- the title to place in the banner.message
- a message to print right below the banner.public String createRepeats(char ch, int n)
ch
- the char to repeat.n
- the number of times to repeat ch.
public void printColumnVectors(Vec3d N, Vec3d B, Vec3d T)
N
- normal - the 3rd column vector of the rotation matrix.B
- binormal - the 2nd column vector of the rotation matrix.T
- tangent - the 1st column vector of the rotation matrix.public void convertToQuaternionAndPrint(Vec3d N, Vec3d B, Vec3d T)
N
- normal - the 1st column vector of the rotation matrix.B
- binormal - the 2nd column vector of the rotation matrix.T
- tangent - the 3rd column vector of the rotation matrix.public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |