MaxstAR Native Android
Public Member Functions | List of all members
com.maxst.ar.Quaternion Class Reference
Inheritance diagram for com.maxst.ar.Quaternion:
com.maxst.ar.Vector4f

Public Member Functions

 Quaternion ()
 
void normalise ()
 
void normalize ()
 
void set (Quaternion quat)
 
void multiplyByQuat (Quaternion input, Quaternion output)
 
void multiplyByQuat (Quaternion input)
 
void multiplyByScalar (float scalar)
 
void addQuat (Quaternion input)
 
void addQuat (Quaternion input, Quaternion output)
 
void subQuat (Quaternion input)
 
void subQuat (Quaternion input, Quaternion output)
 
void toAxisAngle (Vector4f output)
 
double[] toEulerAngles ()
 
void loadIdentityQuat ()
 
String toString ()
 
void setColumnMajor (float[] matrix)
 
void setRowMajor (float[] matrix)
 
void setEulerAngle (float azimuth, float pitch, float roll)
 
void setAxisAngle (Vector3f vec, float rot)
 
void setAxisAngleRad (Vector3f vec, double rot)
 
MatrixF4x4 getMatrix4x4 ()
 
void copyFromVec3 (Vector3f vec, float w)
 
void slerp (Quaternion input, Quaternion output, float t)
 
- Public Member Functions inherited from com.maxst.ar.Vector4f
 Vector4f (float x, float y, float z, float w)
 
 Vector4f ()
 
 Vector4f (Vector3f vector3f, float w)
 
float[] array ()
 
void copyVec4 (Vector4f vec)
 
void add (Vector4f vector)
 
void add (Vector3f vector, float w)
 
void subtract (Vector4f vector)
 
void subtract (Vector4f vector, Vector4f output)
 
void subdivide (Vector4f vector)
 
float dotProduct (Vector4f input)
 
void lerp (Vector4f input, Vector4f output, float t)
 
float getX ()
 
float getY ()
 
float getZ ()
 
float getW ()
 
void setX (float x)
 
void setY (float y)
 
void setZ (float z)
 
void setW (float w)
 
float x ()
 
float y ()
 
float z ()
 
float w ()
 
void x (float x)
 
void y (float y)
 
void z (float z)
 
void w (float w)
 
void setXYZW (float x, float y, float z, float w)
 
boolean compareTo (Vector4f rhs)
 
void copyFromV3f (Vector3f input, float w)
 

Additional Inherited Members

- Protected Attributes inherited from com.maxst.ar.Vector4f
float points [] = { 0, 0, 0, 0 }
 

Detailed Description

The Quaternion class. A Quaternion is a four-dimensional vector that is used to represent rotations of a rigid body in the 3D space. It is very similar to a rotation vector; it contains an angle, encoded into the w component and three components to describe the rotation-axis (encoded into x, y, z).

Quaternions allow for elegant descriptions of 3D rotations, interpolations as well as extrapolations and compared to Euler angles, they don't suffer from gimbal lock. Interpolations between two Quaternions are called SLERP (Spherical Linear Interpolation).

This class also contains the representation of the same rotation as a Quaternion and 4x4-Rotation-Matrix.

Author
Leigh Beattie, Alexander Pacha

Constructor & Destructor Documentation

◆ Quaternion()

com.maxst.ar.Quaternion.Quaternion ( )

Creates a new Quaternion object and initialises it with the identity Quaternion

Member Function Documentation

◆ addQuat() [1/2]

void com.maxst.ar.Quaternion.addQuat ( Quaternion  input)

Add a quaternion to this quaternion

Parameters
inputThe quaternion that you want to add to this one

◆ addQuat() [2/2]

void com.maxst.ar.Quaternion.addQuat ( Quaternion  input,
Quaternion  output 
)

Add this quaternion and another quaternion together and store the result in the output quaternion

Parameters
inputThe quaternion you want added to this quaternion
outputThe quaternion you want to store the output in.

◆ getMatrix4x4()

MatrixF4x4 com.maxst.ar.Quaternion.getMatrix4x4 ( )
Returns
Returns this Quaternion in the Rotation Matrix representation

◆ loadIdentityQuat()

void com.maxst.ar.Quaternion.loadIdentityQuat ( )

Sets the quaternion to an identity quaternion of 0,0,0,1.

◆ multiplyByQuat() [1/2]

void com.maxst.ar.Quaternion.multiplyByQuat ( Quaternion  input)

Multiply this quaternion by the input quaternion and store the result in the out quaternion

Parameters
input
output

◆ multiplyByQuat() [2/2]

void com.maxst.ar.Quaternion.multiplyByQuat ( Quaternion  input,
Quaternion  output 
)

Multiply this quaternion by the input quaternion and store the result in the out quaternion

Parameters
input
output

◆ multiplyByScalar()

void com.maxst.ar.Quaternion.multiplyByScalar ( float  scalar)

Multiplies this Quaternion with a scalar

Parameters
scalarthe value that the vector should be multiplied with

Reimplemented from com.maxst.ar.Vector4f.

◆ normalise()

void com.maxst.ar.Quaternion.normalise ( )

Normalise this Quaternion into a unity Quaternion.

◆ normalize()

void com.maxst.ar.Quaternion.normalize ( )

Normalize.

Reimplemented from com.maxst.ar.Vector4f.

◆ set()

void com.maxst.ar.Quaternion.set ( Quaternion  quat)

Copies the values from the given quaternion to this one

Parameters
quatThe quaternion to copy from

◆ setAxisAngle()

void com.maxst.ar.Quaternion.setAxisAngle ( Vector3f  vec,
float  rot 
)

Rotation is in degrees. Set this quaternion from the supplied axis angle.

Parameters
vecThe vector of rotation
rotThe angle of rotation around that vector in degrees.

◆ setColumnMajor()

void com.maxst.ar.Quaternion.setColumnMajor ( float[]  matrix)

You can set the values for this quaternion based off a rotation matrix. If the matrix you supply is not a rotation matrix this will fail. You MUST provide a 4x4 matrix.

Parameters
matrixA column major rotation matrix

◆ setEulerAngle()

void com.maxst.ar.Quaternion.setEulerAngle ( float  azimuth,
float  pitch,
float  roll 
)

Set this quaternion from axis angle values. All rotations are in degrees.

Parameters
azimuthThe rotation around the z axis
pitchThe rotation around the y axis
rollThe rotation around the x axis

◆ setRowMajor()

void com.maxst.ar.Quaternion.setRowMajor ( float[]  matrix)

You can set the values for this quaternion based off a rotation matrix. If the matrix you supply is not a rotation matrix this will fail.

Parameters
matrixA column major rotation matrix

◆ slerp()

void com.maxst.ar.Quaternion.slerp ( Quaternion  input,
Quaternion  output,
float  t 
)

Get a linear interpolation between this quaternion and the input quaternion, storing the result in the output quaternion.

Parameters
inputThe quaternion to be slerped with this quaternion.
outputThe quaternion to store the result in.
tThe ratio between the two quaternions where 0 <= t <= 1.0 . Increase value of t will bring rotation closer to the input quaternion.

if(dot < 0.95f){ double angle = Math.acos(dot); double ratioA = Math.sin((1 - t) * angle); double ratioB = Math.sin(t * angle); double divisor = Math.sin(angle);

//Calculate Quaternion output.setW((float)((this.getW() * ratioA + input.getW() * ratioB)/divisor)); output.setX((float)((this.getX() * ratioA + input.getX() * ratioB)/divisor)); output.setY((float)((this.getY() * ratioA + input.getY() * ratioB)/divisor)); output.setZ((float)((this.getZ() * ratioA + input.getZ() * ratioB)/divisor)); } else{ lerp(input, output, t); }

◆ subQuat() [1/2]

void com.maxst.ar.Quaternion.subQuat ( Quaternion  input)

Subtract a quaternion to this quaternion

Parameters
inputThe quaternion that you want to subtracted from this one

◆ subQuat() [2/2]

void com.maxst.ar.Quaternion.subQuat ( Quaternion  input,
Quaternion  output 
)

Subtract another quaternion from this quaternion and store the result in the output quaternion

Parameters
inputThe quaternion you want subtracted from this quaternion
outputThe quaternion you want to store the output in.

◆ toAxisAngle()

void com.maxst.ar.Quaternion.toAxisAngle ( Vector4f  output)

Get an axis angle representation of this quaternion.

Parameters
outputVector4f axis angle.

◆ toEulerAngles()

double [] com.maxst.ar.Quaternion.toEulerAngles ( )

Returns the heading, attitude and bank of this quaternion as euler angles in the double array respectively

Returns
An array of size 3 containing the euler angles for this quaternion

The documentation for this class was generated from the following file: