hmi.math
Class Quat4f

java.lang.Object
  extended by hmi.math.Quat4f

public final class Quat4f
extends Object

A collection of static methods for quaternions, represented by float arrays of length four. Note that quaternions are also Vec4f elements, so many methods from Vec4f can be used for quaternions too.

Author:
Job Zwiers, Herwin van Welbergen

Field Summary
static double EPS
           
static double EPS2
           
static double EPSEXPMAP
           
static double MACHINE_EPS
           
private static float PI_DEGREES
           
static int QUAT4F_SIZE
          Length of Quat4f arrays is 4
static int s
           
static int S
          Offset values for quaternion s, x, y, and z components q = (s, (x,y,z)), where s is the scalar part, x, y, z are the imaginary parts.
static double SLERPEPSILON
           
static int x
           
static int X
           
static int y
           
static int Y
           
static int z
           
static int Z
           
 
Constructor Summary
private Quat4f()
           
 
Method Summary
static void add(float[] dst, float[] a)
          Adds quaternions a to quaternion dst.
static void conjugate(float[] a)
          replaces quaternion a by its conjugate.
static void conjugate(float[] a, float[] b)
          replaces quaternion a by the conjugate of quaternion b
static void conjugate(float[] a, int aIndex)
          replaces quaternion a by its conjugate.
static void conjugate(float[] a, int aIndex, float[] b, int bIndex)
          replaces quaternion a by the conjugate of quaternion b
static boolean epsilonEquals(float[] a, float[] b, float epsilon)
          Tests for equality of quaternion components within epsilon.
static boolean epsilonEquals(float[] a, float bs, float bx, float by, float bz, float epsilon)
          Tests for equality of quaternion components within epsilon.
static boolean epsilonEquals(float[] a, int aIndex, float[] b, int bIndex, float epsilon)
          Tests for equality of quaternion components within epsilon.
static boolean equals(float[] a, float[] b)
          Tests for equality of two quaternions
static boolean equals(float[] a, int aIndex, float[] b, int bIndex)
          Tests for equality of two quaternions
static void exp(float[] q, float[] v)
          q = e^v
static String explainQuat4f(float[] q)
           
static String explainQuat4f(float[] q, int fieldwidth, int precision)
           
static float[] getAxisAngle4fFromQuat4f(float[] q)
          Encodes a Quat4f value into AxisAngle4f format and returns the latter in a new float[4] array
static float[] getFromVectors(float[] a, float[] b)
           
static float[] getIdentity()
          Returns a new float[4] array initialized to the identity Quat4f values: (1, 0, 0, 0)
static float[] getQuat4f()
          Returns a new float[4] array with zero components Note that this is NOT the identity.
static float[] getQuat4f(float[] q)
          Returns a new float[4] array with initialized components
static float[] getQuat4f(float s, float x, float y, float z)
          Returns a new float[4] array with specified components No check is made that this is a unit quaternion
static float[] getQuat4fFromAxisAngle(float x, float y, float z, float angle)
          Returns a new quaternion float[4] array, specifuing a rotation around axis (x, y, z), with angle specified in radians.
static float[] getQuat4fFromAxisAngleDegrees(float x, float y, float z, float degrees)
          Returns a new quaternion float[4] array, specifuing a rotation around axis (x, y, z), with angle specified in degrees.
static float[] getQuat4fFromRollPitchYawDegrees(float roll, float pitch, float yaw)
          Returns a new float[4] array with specified components No check is made that this is a unit quaternion
static void getRollPitchYaw(float[] q, float[] result)
          calculates the roll,pitch, and yaw angles from a quaternion
static void interpolate(float[] qr, float[] q, float alpha)
          Performs a great circle interpolation (slerp) between two quaternions qr and q, and places the result back into quaternion qr.
static void interpolate(float[] qr, float[] q1, float[] q2, float alpha)
          Performs a great circle interpolation (slerp) between two quaternions q1 and q2, and places the result in quaternion qr.
static void interpolate(float[] qr, int qrIndex, float[] q1, int q1Index, float[] q2, int q2Index, float alpha)
          Performs a great circle interpolation (slerp) between quaternions taken from arrays q1 and q2, and places the results in array qr.
static void interpolateArrays(float[] qr, float[] q1, float[] q2, float alpha)
          Performs a great circle interpolation (slerp) between quaternions taken from arrays q1 and q2, and places the results in array qr.
static void inverse(float[] a)
          replaces quaternion a by its inverse.
static void inverse(float[] a, float[] b)
          replaces quaternion a by the inverse of quaternion b It is not assumed that b is normalized, i.e. it need not have length 1.
static boolean isIdentity(float[] dst)
          Sets quaternion components to (1.0, 0.0, 0.0, 0.0) This is a unit quaternion, representing the identity transform.
static float length(float[] a)
          returns the quaternion length
static float lengthSq(float[] a)
          returns the square of the quaternion length
static void log(float[] v, float[] q)
          v = log q
static void mul(float[] a, float[] b)
          Multiplies two quaternions, and puts the result back in a: a = a * b
static void mul(float[] c, float[] a, float[] b)
          Multiplies two quaternions, and puts the result in c: c = a * b
static void mul(float[] a, int aIndex, float[] b, int bIndex)
          Multiplies two quaternions, and puts the result back in a: a = a * b
static void mul(float[] c, int ci, float[] a, int ai, float[] b, int bi)
          Multiplies two quaternions, and puts the result in c: c = a * b
static void mulConjugateRight(float[] a, float[] b)
          Multiplies a quaternion, with the conjugate of another quaternion and puts the result back in a: a = a * conjugate(b)
static void mulConjugateRight(float[] c, float[] a, float[] b)
          Multiplies a quaternion, with the conjugate of another quaternion and puts the result in c: c = a * conjugate(b)
static void mulConjugateRight(float[] a, int aIndex, float[] b, int bIndex)
          Multiplies a quaternion, with the conjugate of another quaternion and puts the result back in a: a = a * conjugate(b)
static void mulConjugateRight(float[] c, int cIndex, float[] a, int aIndex, float[] b, int bIndex)
          Multiplies a quaternion, with the conjugate of another quaternion and puts the result in c: c = a * conjugate(b)
static void normalize(float[] a)
          Normalizes the value of quaternion a.
static void normalize(float[] a, float[] b)
          Sets quaternion a to the normalized version of quaternion b.
static void normalize(float[] a, int aIndex)
          Normalizes the value of quaternion a.
static void pow(float[] qin, float p)
          qin=qin^p
static void pow(float[] qout, float p, float[] qin)
          Calculates qout=qin^p = exp(log(q)p)
static void set(float[] dst, float[] src)
          Copies quaternion src to vector dst
static void set(float[] dst, float qs, float qx, float qy, float qz)
          Sets quaternion components to specified float values.
static void set(float[] dst, int dIndex, float[] src, int sIndex)
          Copies quaternion src to vector dst
static void set(float[] dst, int index, float qs, float qx, float qy, float qz)
          Sets quaternion components to specified float values.
static void setAngularAccelerationFromQuat4f(float[] aacc, float[] q, float[] qratediff)
          Calculates the instantatious angular acceleration from the quaternion, quaternion rate and quaternion rate diff [s w']^T = 2 * qrate' * q^-1
static void setAngularAccelerationFromQuat4f(float[] aacc, int aaccIndex, float[] q, int qIndex, float[] qratediff, int qRateDiffIndex)
          Calculates the instantatious angular acceleration from the quaternion, quaternion rate and quaternion rate diff a = w' = 2*qrate'*(q^-1)
static void setAngularVelocityFromQuat4f(float[] avel, float[] q, float[] qrate)
          Calculates the instantatious angular velocity from the quaternion rate and quaternion rotation w = 2*qrate*q^-1
static void setAngularVelocityFromQuat4f(float[] avel, int aVelIndex, float[] q, int qIndex, float[] qrate, int qRateIndex)
          Calculates the instantatious angular velocity from the quaternion rate and quaternion rotation w = 2*qrate*q^-1
static void setAxisAngle4fFromQuat4f(float[] aa, float[] q)
          Encodes a Quat4f value into AxisAngle4f format assumes that q is a normalized quaternion
static void setFromAxisAngle4f(float[] q, float[] aa)
          Like setFromAxisAngle4f(ax, ay, az, angle), where the axis is ([[[0], aa[1], aa[2]), and the angle is aa[3].
static void setFromAxisAngle4f(float[] q, float ax, float ay, float az, float angle)
          Sets the quaternion coefficients from a rotation axis (ax, ay, az) and a rotation angle, in radians.
static void setFromAxisAngle4f(float[] q, int qIndex, float[] aa, int aaIndex)
          Sets the quaternion coefficients from a rotation axis (ax, ay, az) and a rotation angle.
static void setFromAxisAngle4f(float[] q, int qIndex, float ax, float ay, float az, float angle)
          Sets the quaternion coefficients from a rotation axis (ax, ay, az) and a rotation angle.
static void setFromAxisAngleDegrees(float[] q, float[] axis, float degrees)
          Sets the quaternion coefficients from a rotation axis-angle in a float[4] array.
static void setFromAxisAngleDegrees(float[] q, float ax, float ay, float az, float degrees)
          Sets the quaternion coefficients from a rotation axis-angle in a float[4] array.
static void setFromEulerAngles(float[] q, float[] ea)
          Convert Euler angles to quaternion coefficients.
static void setFromEulerAngles(float[] q, float heading, float attitude, float bank)
          Convert Euler angles to quaternion coefficients.
static void setFromMat3f(float[] q, float[] m)
          Calculates the quaternion q elements from a 3X3 matrix m, assuming that the latter does not include scaling and/or skewing.
static void setFromMat4f(float[] q, float[] m)
          Calculates the quaternion q elements from a 4X4 or 4X3 matrix m, assuming that the latter does not include scaling and/or skewing.
static void setFromRollPitchYaw(float[] q, float roll, float pitch, float yaw)
          calculates a quaternion representation from "roll-pitch-yaw" angles specifies in radians.
static void setFromRollPitchYawDegrees(float[] q, float roll, float pitch, float yaw)
          Like setFromRollPitchYaw, but with angles specified in degrees, rather than in radians.
static void setFromVectors(float[] q, float[] a, float[] b)
          Sets the Quaternions q from Vec3f vectors a and b The quaternion is such that it rotates vectors in the a direction towards vectors in the b direction.
static void setIdentity(float[] dst)
          Sets quaternion components to (1.0, 0.0, 0.0, 0.0) This is a unit quaternion, representing the identity transform.
static void setIdentity(float[] dst, int qIndex)
          Sets quaternion components to (1.0, 0.0, 0.0, 0.0) This is a unit quaternion, representing the identity transform.
static void setQuat4fArrayFromAxisAngle4fArray(float[] q, float[] aa)
          Sets an array of Quat4f quadruples from a similar aray of axis-angle quadruples.
static void smooth(float[] q, float eps)
          Quats close to either (1.0, 0.0, 0.0, 0.0) or (-1.0, 0.0, 0.0, 0.0) are rounded towards these values, provided the first element deviates less from 1 or -1 by an amount eps
static void sub(float[] dst, float[] a)
          Subtracts quaternion a from quaternion dst.
static String toString(float[] a)
           
static String toString(float[] a, int aIndex)
           
static String toString(float[] a, int fieldwidth, int precision)
          Returns a String of the form (x, y, z), representing the Vec3f value.
static String toString(float[] a, String fmt)
          Returns a String of the form (a0, a1, a2, a3), representing the Quat4f value.
static float[] transformVec3f(float[] q, float[] v)
          rotates a vector with a quaternion, assumes the quaternion is length 1 transforms v, and also returns it.
static float[] transformVec3f(float[] q, int qIndex, float[] v, int vIndex)
          rotates a vector with a quaternion, assumes the quaternion is length 1 transforms v, and also returns it.
static void transformVec3f(float[] q, int qIndex, float[] src, int srcIndex, float[] dst, int dstIndex)
          rotates a vector with a quaternion, assumes the quaternion is length 1 transforms v, and also returns it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUAT4F_SIZE

public static final int QUAT4F_SIZE
Length of Quat4f arrays is 4

See Also:
Constant Field Values

S

public static final int S
Offset values for quaternion s, x, y, and z components q = (s, (x,y,z)), where s is the scalar part, x, y, z are the imaginary parts.

See Also:
Constant Field Values

X

public static final int X
See Also:
Constant Field Values

Y

public static final int Y
See Also:
Constant Field Values

Z

public static final int Z
See Also:
Constant Field Values

s

public static final int s
See Also:
Constant Field Values

x

public static final int x
See Also:
Constant Field Values

y

public static final int y
See Also:
Constant Field Values

z

public static final int z
See Also:
Constant Field Values

EPS2

public static final double EPS2
See Also:
Constant Field Values

EPS

public static final double EPS
See Also:
Constant Field Values

MACHINE_EPS

public static final double MACHINE_EPS
See Also:
Constant Field Values

EPSEXPMAP

public static final double EPSEXPMAP
See Also:
Constant Field Values

SLERPEPSILON

public static final double SLERPEPSILON
See Also:
Constant Field Values

PI_DEGREES

private static final float PI_DEGREES
See Also:
Constant Field Values
Constructor Detail

Quat4f

private Quat4f()
Method Detail

getQuat4f

public static float[] getQuat4f()
Returns a new float[4] array with zero components Note that this is NOT the identity.


exp

public static void exp(float[] q,
                       float[] v)
q = e^v

Parameters:
q - destination
v - the exponential map rotation (Vec3f) |v|=alpha, v/|v|=rotation axis, v==q is allowed Uses implementation from: Grassia, Sebastian F., Practical Parameterization of Rotations Using the Exponential Map (1998), in: journal of graphics tools, 3:3(29--48) A Taylor expansion is used to calculate the quaternion accuratly for small angles

log

public static void log(float[] v,
                       float[] q)
v = log q

Parameters:
v - destination: the exponential map rotation (Vec3f) |v|=alpha, v/|v|=rotation axis
q - rotation v==q is allowed Uses implementation from: Grassia, Sebastian F., Practical Parameterization of Rotations Using the Exponential Map (1998), in: journal of graphics tools, 3:3(29--48) A Taylor expansion is used to calculate the exponential map accuratly for small angles

getQuat4f

public static float[] getQuat4f(float s,
                                float x,
                                float y,
                                float z)
Returns a new float[4] array with specified components No check is made that this is a unit quaternion


getIdentity

public static float[] getIdentity()
Returns a new float[4] array initialized to the identity Quat4f values: (1, 0, 0, 0)


getQuat4f

public static float[] getQuat4f(float[] q)
Returns a new float[4] array with initialized components


getQuat4fFromAxisAngle

public static float[] getQuat4fFromAxisAngle(float x,
                                             float y,
                                             float z,
                                             float angle)
Returns a new quaternion float[4] array, specifuing a rotation around axis (x, y, z), with angle specified in radians.


getQuat4fFromAxisAngleDegrees

public static float[] getQuat4fFromAxisAngleDegrees(float x,
                                                    float y,
                                                    float z,
                                                    float degrees)
Returns a new quaternion float[4] array, specifuing a rotation around axis (x, y, z), with angle specified in degrees.


getQuat4fFromRollPitchYawDegrees

public static float[] getQuat4fFromRollPitchYawDegrees(float roll,
                                                       float pitch,
                                                       float yaw)
Returns a new float[4] array with specified components No check is made that this is a unit quaternion


add

public static void add(float[] dst,
                       float[] a)
Adds quaternions a to quaternion dst.


sub

public static void sub(float[] dst,
                       float[] a)
Subtracts quaternion a from quaternion dst.


equals

public static boolean equals(float[] a,
                             float[] b)
Tests for equality of two quaternions


equals

public static boolean equals(float[] a,
                             int aIndex,
                             float[] b,
                             int bIndex)
Tests for equality of two quaternions


epsilonEquals

public static boolean epsilonEquals(float[] a,
                                    float[] b,
                                    float epsilon)
Tests for equality of quaternion components within epsilon.


epsilonEquals

public static boolean epsilonEquals(float[] a,
                                    float bs,
                                    float bx,
                                    float by,
                                    float bz,
                                    float epsilon)
Tests for equality of quaternion components within epsilon.


epsilonEquals

public static boolean epsilonEquals(float[] a,
                                    int aIndex,
                                    float[] b,
                                    int bIndex,
                                    float epsilon)
Tests for equality of quaternion components within epsilon.


setFromEulerAngles

public static void setFromEulerAngles(float[] q,
                                      float heading,
                                      float attitude,
                                      float bank)
Convert Euler angles to quaternion coefficients. Which angles, which order, which signs of the angles?


setFromRollPitchYawDegrees

public static void setFromRollPitchYawDegrees(float[] q,
                                              float roll,
                                              float pitch,
                                              float yaw)
Like setFromRollPitchYaw, but with angles specified in degrees, rather than in radians.


setFromRollPitchYaw

public static void setFromRollPitchYaw(float[] q,
                                       float roll,
                                       float pitch,
                                       float yaw)
calculates a quaternion representation from "roll-pitch-yaw" angles specifies in radians. This is a rotation of the form Ry(yaw) o Rx(pitch) o Rz(roll). So, the roll is around the Z axis, pitch around the X axis, and yaw around the Y axis. Informally, roll is in the objects own coordinate system, pitch is the angle between the objects own axis and the X-Z plane, and yaw is the "heading", obtained by rotating around the Y-axis. The result (in float precision) is returned in the quaternion array q.


getRollPitchYaw

public static void getRollPitchYaw(float[] q,
                                   float[] result)
calculates the roll,pitch, and yaw angles from a quaternion


setFromVectors

public static void setFromVectors(float[] q,
                                  float[] a,
                                  float[] b)
Sets the Quaternions q from Vec3f vectors a and b The quaternion is such that it rotates vectors in the a direction towards vectors in the b direction. (If a and b happen to have the same length, a would be rotated into b)


getFromVectors

public static float[] getFromVectors(float[] a,
                                     float[] b)

set

public static void set(float[] dst,
                       float[] src)
Copies quaternion src to vector dst


set

public static void set(float[] dst,
                       int dIndex,
                       float[] src,
                       int sIndex)
Copies quaternion src to vector dst


set

public static void set(float[] dst,
                       float qs,
                       float qx,
                       float qy,
                       float qz)
Sets quaternion components to specified float values.


set

public static void set(float[] dst,
                       int index,
                       float qs,
                       float qx,
                       float qy,
                       float qz)
Sets quaternion components to specified float values.


setIdentity

public static void setIdentity(float[] dst)
Sets quaternion components to (1.0, 0.0, 0.0, 0.0) This is a unit quaternion, representing the identity transform.


setIdentity

public static void setIdentity(float[] dst,
                               int qIndex)
Sets quaternion components to (1.0, 0.0, 0.0, 0.0) This is a unit quaternion, representing the identity transform.


isIdentity

public static boolean isIdentity(float[] dst)
Sets quaternion components to (1.0, 0.0, 0.0, 0.0) This is a unit quaternion, representing the identity transform.


setFromEulerAngles

public static void setFromEulerAngles(float[] q,
                                      float[] ea)
Convert Euler angles to quaternion coefficients.


setFromAxisAngleDegrees

public static void setFromAxisAngleDegrees(float[] q,
                                           float[] axis,
                                           float degrees)
Sets the quaternion coefficients from a rotation axis-angle in a float[4] array. The angle in radians. The axis need not have length 1. If it has length 0, q is set to the unit quaternion (1, 0, 0, 0).


setFromAxisAngleDegrees

public static void setFromAxisAngleDegrees(float[] q,
                                           float ax,
                                           float ay,
                                           float az,
                                           float degrees)
Sets the quaternion coefficients from a rotation axis-angle in a float[4] array. The angle in radians. The axis need not have length 1. If it has length 0, q is set to the unit quaternion (1, 0, 0, 0).


setFromAxisAngle4f

public static void setFromAxisAngle4f(float[] q,
                                      float[] aa)
Like setFromAxisAngle4f(ax, ay, az, angle), where the axis is ([[[0], aa[1], aa[2]), and the angle is aa[3].


setFromAxisAngle4f

public static void setFromAxisAngle4f(float[] q,
                                      float ax,
                                      float ay,
                                      float az,
                                      float angle)
Sets the quaternion coefficients from a rotation axis (ax, ay, az) and a rotation angle, in radians. The axis need not have length 1. If it has length 0, q is set to the unit quaternion (1, 0, 0, 0).


setQuat4fArrayFromAxisAngle4fArray

public static void setQuat4fArrayFromAxisAngle4fArray(float[] q,
                                                      float[] aa)
Sets an array of Quat4f quadruples from a similar aray of axis-angle quadruples. The conversion for each individual axis-angle is the same as affected by setFromAxisAngle4f


setFromAxisAngle4f

public static void setFromAxisAngle4f(float[] q,
                                      int qIndex,
                                      float[] aa,
                                      int aaIndex)
Sets the quaternion coefficients from a rotation axis (ax, ay, az) and a rotation angle. The axis need not have length 1. If it has length 0, q is set to the unit quaternion (1, 0, 0, 0).


setFromAxisAngle4f

public static void setFromAxisAngle4f(float[] q,
                                      int qIndex,
                                      float ax,
                                      float ay,
                                      float az,
                                      float angle)
Sets the quaternion coefficients from a rotation axis (ax, ay, az) and a rotation angle. The axis need not have length 1. If it has length 0, q is set to the unit quaternion (1, 0, 0, 0).


setAxisAngle4fFromQuat4f

public static void setAxisAngle4fFromQuat4f(float[] aa,
                                            float[] q)
Encodes a Quat4f value into AxisAngle4f format assumes that q is a normalized quaternion


getAxisAngle4fFromQuat4f

public static float[] getAxisAngle4fFromQuat4f(float[] q)
Encodes a Quat4f value into AxisAngle4f format and returns the latter in a new float[4] array


setFromMat3f

public static void setFromMat3f(float[] q,
                                float[] m)
Calculates the quaternion q elements from a 3X3 matrix m, assuming that the latter does not include scaling and/or skewing.


setFromMat4f

public static void setFromMat4f(float[] q,
                                float[] m)
Calculates the quaternion q elements from a 4X4 or 4X3 matrix m, assuming that the latter does not include scaling and/or skewing. For a 4X4 matrix, we assume that the m33 elements equals 1.0


mul

public static void mul(float[] c,
                       int ci,
                       float[] a,
                       int ai,
                       float[] b,
                       int bi)
Multiplies two quaternions, and puts the result in c: c = a * b


mul

public static void mul(float[] c,
                       float[] a,
                       float[] b)
Multiplies two quaternions, and puts the result in c: c = a * b


mulConjugateRight

public static void mulConjugateRight(float[] c,
                                     float[] a,
                                     float[] b)
Multiplies a quaternion, with the conjugate of another quaternion and puts the result in c: c = a * conjugate(b)


mulConjugateRight

public static void mulConjugateRight(float[] c,
                                     int cIndex,
                                     float[] a,
                                     int aIndex,
                                     float[] b,
                                     int bIndex)
Multiplies a quaternion, with the conjugate of another quaternion and puts the result in c: c = a * conjugate(b)


mulConjugateRight

public static void mulConjugateRight(float[] a,
                                     float[] b)
Multiplies a quaternion, with the conjugate of another quaternion and puts the result back in a: a = a * conjugate(b)


mulConjugateRight

public static void mulConjugateRight(float[] a,
                                     int aIndex,
                                     float[] b,
                                     int bIndex)
Multiplies a quaternion, with the conjugate of another quaternion and puts the result back in a: a = a * conjugate(b)


mul

public static void mul(float[] a,
                       float[] b)
Multiplies two quaternions, and puts the result back in a: a = a * b


mul

public static void mul(float[] a,
                       int aIndex,
                       float[] b,
                       int bIndex)
Multiplies two quaternions, and puts the result back in a: a = a * b


conjugate

public static void conjugate(float[] a,
                             int aIndex)
replaces quaternion a by its conjugate. (x, y, z components negated, scalar component s unchanged)


conjugate

public static void conjugate(float[] a)
replaces quaternion a by its conjugate. (x, y, z components negated, s component unchanged)


conjugate

public static void conjugate(float[] a,
                             float[] b)
replaces quaternion a by the conjugate of quaternion b


conjugate

public static void conjugate(float[] a,
                             int aIndex,
                             float[] b,
                             int bIndex)
replaces quaternion a by the conjugate of quaternion b


inverse

public static void inverse(float[] a)
replaces quaternion a by its inverse. It is not assumed that the quaternion is normalized, i.e. it need not have length 1.


inverse

public static void inverse(float[] a,
                           float[] b)
replaces quaternion a by the inverse of quaternion b It is not assumed that b is normalized, i.e. it need not have length 1.


lengthSq

public static float lengthSq(float[] a)
returns the square of the quaternion length


length

public static float length(float[] a)
returns the quaternion length


normalize

public static void normalize(float[] a,
                             int aIndex)
Normalizes the value of quaternion a.


normalize

public static void normalize(float[] a)
Normalizes the value of quaternion a.


normalize

public static void normalize(float[] a,
                             float[] b)
Sets quaternion a to the normalized version of quaternion b.


interpolate

public static void interpolate(float[] qr,
                               float[] q1,
                               float[] q2,
                               float alpha)
Performs a great circle interpolation (slerp) between two quaternions q1 and q2, and places the result in quaternion qr.


interpolate

public static void interpolate(float[] qr,
                               float[] q,
                               float alpha)
Performs a great circle interpolation (slerp) between two quaternions qr and q, and places the result back into quaternion qr.


interpolate

public static void interpolate(float[] qr,
                               int qrIndex,
                               float[] q1,
                               int q1Index,
                               float[] q2,
                               int q2Index,
                               float alpha)
Performs a great circle interpolation (slerp) between quaternions taken from arrays q1 and q2, and places the results in array qr. The arrays are assumed to have equals size, which should be a mutiple of 4. Each consecutive four floats are considered to be one quaternion in the standard order: (s, x, y, z).


interpolateArrays

public static void interpolateArrays(float[] qr,
                                     float[] q1,
                                     float[] q2,
                                     float alpha)
Performs a great circle interpolation (slerp) between quaternions taken from arrays q1 and q2, and places the results in array qr. The arrays are assumed to have equals size, which should be a mutiple of 4. Each consecutive four floats are considered to be one quaternion in the standard order: (s, x, y, z).


transformVec3f

public static float[] transformVec3f(float[] q,
                                     int qIndex,
                                     float[] v,
                                     int vIndex)
rotates a vector with a quaternion, assumes the quaternion is length 1 transforms v, and also returns it.


transformVec3f

public static void transformVec3f(float[] q,
                                  int qIndex,
                                  float[] src,
                                  int srcIndex,
                                  float[] dst,
                                  int dstIndex)
rotates a vector with a quaternion, assumes the quaternion is length 1 transforms v, and also returns it.


transformVec3f

public static float[] transformVec3f(float[] q,
                                     float[] v)
rotates a vector with a quaternion, assumes the quaternion is length 1 transforms v, and also returns it.


toString

public static String toString(float[] a,
                              int aIndex)

toString

public static String toString(float[] a)

toString

public static String toString(float[] a,
                              int fieldwidth,
                              int precision)
Returns a String of the form (x, y, z), representing the Vec3f value.


toString

public static String toString(float[] a,
                              String fmt)
Returns a String of the form (a0, a1, a2, a3), representing the Quat4f value.


explainQuat4f

public static String explainQuat4f(float[] q,
                                   int fieldwidth,
                                   int precision)

explainQuat4f

public static String explainQuat4f(float[] q)

pow

public static void pow(float[] qout,
                       float p,
                       float[] qin)
Calculates qout=qin^p = exp(log(q)p)


pow

public static void pow(float[] qin,
                       float p)
qin=qin^p


setAngularVelocityFromQuat4f

public static void setAngularVelocityFromQuat4f(float[] avel,
                                                float[] q,
                                                float[] qrate)
Calculates the instantatious angular velocity from the quaternion rate and quaternion rotation w = 2*qrate*q^-1


setAngularVelocityFromQuat4f

public static void setAngularVelocityFromQuat4f(float[] avel,
                                                int aVelIndex,
                                                float[] q,
                                                int qIndex,
                                                float[] qrate,
                                                int qRateIndex)
Calculates the instantatious angular velocity from the quaternion rate and quaternion rotation w = 2*qrate*q^-1


setAngularAccelerationFromQuat4f

public static void setAngularAccelerationFromQuat4f(float[] aacc,
                                                    float[] q,
                                                    float[] qratediff)
Calculates the instantatious angular acceleration from the quaternion, quaternion rate and quaternion rate diff [s w']^T = 2 * qrate' * q^-1


setAngularAccelerationFromQuat4f

public static void setAngularAccelerationFromQuat4f(float[] aacc,
                                                    int aaccIndex,
                                                    float[] q,
                                                    int qIndex,
                                                    float[] qratediff,
                                                    int qRateDiffIndex)
Calculates the instantatious angular acceleration from the quaternion, quaternion rate and quaternion rate diff a = w' = 2*qrate'*(q^-1)


smooth

public static void smooth(float[] q,
                          float eps)
Quats close to either (1.0, 0.0, 0.0, 0.0) or (-1.0, 0.0, 0.0, 0.0) are rounded towards these values, provided the first element deviates less from 1 or -1 by an amount eps