MaxstARSDK
com.maxst.ar.Quaternion Class Reference
Inheritance diagram for com.maxst.ar.Quaternion:
Inheritance graph
Collaboration diagram for com.maxst.ar.Quaternion:
Collaboration graph

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)
 
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 ()
 
void x (float x)
 
float y ()
 
void y (float y)
 
float z ()
 
void z (float z)
 
float w ()
 
void w (float w)
 
void setXYZW (float x, float y, float z, float w)
 
boolean compareTo (Vector4f rhs)
 
void copyFromV3f (Vector3f input, float w)
 

Protected Attributes

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

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ add() [1/2]

void com.maxst.ar.Vector4f.add ( Vector3f  vector,
float  w 
)
inherited
Here is the call graph for this function:

◆ add() [2/2]

void com.maxst.ar.Vector4f.add ( Vector4f  vector)
inherited

Adds the.

Parameters
vectorthe vector

◆ 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.
Here is the call graph for this function:

◆ array()

float [] com.maxst.ar.Vector4f.array ( )
inherited

To array.

Returns
the float[]
Here is the caller graph for this function:

◆ compareTo()

boolean com.maxst.ar.Vector4f.compareTo ( Vector4f  rhs)
inherited

Compare this vector4f to the supplied one

Parameters
rhsTrue if they match, false other wise.
Returns

◆ copyFromV3f()

void com.maxst.ar.Vector4f.copyFromV3f ( Vector3f  input,
float  w 
)
inherited

Copies the data from the supplied vec3 into this vec4 plus the supplied w.

Parameters
inputThe x y z values to copy in.
wThe extra w element to copy in
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyFromVec3()

void com.maxst.ar.Quaternion.copyFromVec3 ( Vector3f  vec,
float  w 
)
Here is the call graph for this function:

◆ copyVec4()

void com.maxst.ar.Vector4f.copyVec4 ( Vector4f  vec)
inherited
Here is the caller graph for this function:

◆ dotProduct()

float com.maxst.ar.Vector4f.dotProduct ( Vector4f  input)
inherited
Here is the caller graph for this function:

◆ getMatrix4x4()

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

◆ getW()

float com.maxst.ar.Vector4f.getW ( )
inherited

Gets the w.

Returns
the w
Here is the caller graph for this function:

◆ getX()

float com.maxst.ar.Vector4f.getX ( )
inherited

Gets the x.

Returns
the x
Here is the caller graph for this function:

◆ getY()

float com.maxst.ar.Vector4f.getY ( )
inherited

Gets the y.

Returns
the y
Here is the caller graph for this function:

◆ getZ()

float com.maxst.ar.Vector4f.getZ ( )
inherited

Gets the z.

Returns
the z
Here is the caller graph for this function:

◆ lerp()

void com.maxst.ar.Vector4f.lerp ( Vector4f  input,
Vector4f  output,
float  t 
)
inherited

Linear interpolation between two vectors storing the result in the output variable.

Parameters
input
output
t

◆ loadIdentityQuat()

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
Here is the call graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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.

Here is the caller graph for this function:

◆ normalize()

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

Normalize.

Reimplemented from com.maxst.ar.Vector4f.

Here is the call graph for this function:

◆ 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
Here is the call graph for this function:

◆ 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.
Here is the call graph for this function:

◆ setAxisAngleRad()

void com.maxst.ar.Quaternion.setAxisAngleRad ( Vector3f  vec,
double  rot 
)
Here is the call graph for this function:

◆ 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
Here is the call graph for this function:

◆ 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

◆ setW()

void com.maxst.ar.Vector4f.setW ( float  w)
inherited

Sets the w.

Parameters
wthe new w
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setX()

void com.maxst.ar.Vector4f.setX ( float  x)
inherited

Sets the x.

Parameters
xthe new x
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setXYZW()

void com.maxst.ar.Vector4f.setXYZW ( float  x,
float  y,
float  z,
float  w 
)
inherited
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setY()

void com.maxst.ar.Vector4f.setY ( float  y)
inherited

Sets the y.

Parameters
ythe new y
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setZ()

void com.maxst.ar.Vector4f.setZ ( float  z)
inherited

Sets the z.

Parameters
zthe new z
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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); }

Here is the call graph for this function:

◆ subdivide()

void com.maxst.ar.Vector4f.subdivide ( Vector4f  vector)
inherited

◆ 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.
Here is the call graph for this function:

◆ subtract() [1/2]

void com.maxst.ar.Vector4f.subtract ( Vector4f  vector)
inherited

◆ subtract() [2/2]

void com.maxst.ar.Vector4f.subtract ( Vector4f  vector,
Vector4f  output 
)
inherited
Here is the call graph for this function:

◆ toAxisAngle()

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

Get an axis angle representation of this quaternion.

Parameters
outputVector4f axis angle.
Here is the call graph for this function:

◆ 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
Here is the call graph for this function:

◆ toString()

String com.maxst.ar.Quaternion.toString ( )

Reimplemented from com.maxst.ar.Vector4f.

Here is the call graph for this function:

◆ w() [1/2]

float com.maxst.ar.Vector4f.w ( )
inherited
Here is the caller graph for this function:

◆ w() [2/2]

void com.maxst.ar.Vector4f.w ( float  w)
inherited
Here is the call graph for this function:

◆ x() [1/2]

float com.maxst.ar.Vector4f.x ( )
inherited
Here is the caller graph for this function:

◆ x() [2/2]

void com.maxst.ar.Vector4f.x ( float  x)
inherited
Here is the call graph for this function:

◆ y() [1/2]

float com.maxst.ar.Vector4f.y ( )
inherited
Here is the caller graph for this function:

◆ y() [2/2]

void com.maxst.ar.Vector4f.y ( float  y)
inherited
Here is the call graph for this function:

◆ z() [1/2]

float com.maxst.ar.Vector4f.z ( )
inherited
Here is the caller graph for this function:

◆ z() [2/2]

void com.maxst.ar.Vector4f.z ( float  z)
inherited
Here is the call graph for this function:

Member Data Documentation

◆ points

float com.maxst.ar.Vector4f.points[] = { 0, 0, 0, 0 }
protectedinherited

The points.


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