gov.sandia.cognition.math.matrix
Interface Quaternion

All Superinterfaces:
Cloneable, CloneableSerializable, Serializable, Vectorizable

public interface Quaternion
extends CloneableSerializable, Vectorizable

Interface for a mathematical quaternion, which represents rotations using four dimensions. This representation is useful for manipulating for animations and for utilizing in machine learning algorithms.

Since:
2.1
Author:
Justin Basilico

Method Summary
 Quaternion clone()
          Clones this object.
 Quaternion compose(Quaternion other)
          Multiplies this * other and returns the result.
 void composeEquals(Quaternion other)
          Multiplies this = this * other, thus modifying this object.
 void convertFromRotationMatrix(Matrix rotationMatrix)
          Sets the quaternion to be equivalent to the given a 3-by-3 rotation matrix.
 Matrix convertToRotationMatrix()
          Converts the quaternion to a 3-by-3 rotation matrix.
 boolean equals(Quaternion other)
          Determines if this quaternion is equal to the given quaternion.
 boolean equals(Quaternion other, double effectiveZero)
          Determines if this quaternion is equal to the given quaternion, using a given threshold for determining if two numbers are equal.
 double getW()
          Gets the w component of the quaternion.
 double getX()
          Gets the x component of the quaternion.
 double getY()
          Gets the y component of the quaternion.
 double getZ()
          Gets the z component of the quaternion.
 Quaternion interpolate(Quaternion other, double alpha)
          Interpolates between this quaternion and the given quaternion.
 void interpolateEquals(Quaternion other, double alpha)
          Interpolates between this quaternion and the given quaternion and sets it in this quaternion.
 Quaternion inverse()
          Returns the inverse of this quaternion.
 void inverseEquals()
          Changes this quaternion to be its inverse.
 Quaternion normalize()
          Returns the normalized version of the quaternion.
 void normalizeEquals()
          Normalizes the quaternion in-place.
 Vector3 rotate(Vector vector)
          Rotates the given vector by this quaternion by performing a multiplication with this quaternion's rotation matrix: M * v.
 void setElements(Quaternion other)
          Sets the elements of this quaternion equal to the elements of the given quaternion.
 void setW(double w)
          Sets the w component of the quaternion.
 void setWXYZ(double w, double x, double y, double z)
          Sets all of the elements of the quaternion in w-x-y-z order.
 void setX(double x)
          Sets the x component of the quaternion.
 void setXYZW(double x, double y, double z, double w)
          Sets all of the elements of the quaternion in x-y-z-w order.
 void setY(double y)
          Sets the y component of the quaternion.
 void setZ(double z)
          Sets the z component of the quaternion.
 
Methods inherited from interface gov.sandia.cognition.math.matrix.Vectorizable
convertFromVector, convertToVector
 

Method Detail

clone

Quaternion clone()
Clones this object.

Specified by:
clone in interface CloneableSerializable
Specified by:
clone in interface Vectorizable
Returns:
A clone of this object.

setElements

void setElements(Quaternion other)
Sets the elements of this quaternion equal to the elements of the given quaternion.

Parameters:
other - The other quaternion to copy the values of.

normalize

Quaternion normalize()
Returns the normalized version of the quaternion.

Returns:
The normalized version of the quaternion.

normalizeEquals

void normalizeEquals()
Normalizes the quaternion in-place.


inverse

Quaternion inverse()
Returns the inverse of this quaternion.

Returns:
The inverse of this quaternion

inverseEquals

void inverseEquals()
Changes this quaternion to be its inverse.


rotate

Vector3 rotate(Vector vector)
Rotates the given vector by this quaternion by performing a multiplication with this quaternion's rotation matrix: M * v.

Parameters:
vector - The 3-dimensional vector to rotate.
Returns:
The vector rotated by this orientation.

compose

Quaternion compose(Quaternion other)
Multiplies this * other and returns the result.

Parameters:
other - The other quaternion to multiply with.
Returns:
The result of the multiplication.

composeEquals

void composeEquals(Quaternion other)
Multiplies this = this * other, thus modifying this object.

Parameters:
other - The other quaternion to multiply with.

interpolate

Quaternion interpolate(Quaternion other,
                       double alpha)
Interpolates between this quaternion and the given quaternion.

Parameters:
other - The other quaternion.
alpha - The interpolation parameter.
Returns:
The interpolated quaternion.

interpolateEquals

void interpolateEquals(Quaternion other,
                       double alpha)
Interpolates between this quaternion and the given quaternion and sets it in this quaternion.

Parameters:
other - The other quaternion.
alpha - The interpolation parameter.

convertToRotationMatrix

Matrix convertToRotationMatrix()
Converts the quaternion to a 3-by-3 rotation matrix.

Returns:
A 3-by-3 rotation matrix.

convertFromRotationMatrix

void convertFromRotationMatrix(Matrix rotationMatrix)
Sets the quaternion to be equivalent to the given a 3-by-3 rotation matrix.

Parameters:
rotationMatrix - A 3-by-3 rotation matrix.

equals

boolean equals(Quaternion other)
Determines if this quaternion is equal to the given quaternion.

Parameters:
other - The other quaternion to determine equality with.
Returns:
True if the two are equal; otherwise, false.

equals

boolean equals(Quaternion other,
               double effectiveZero)
Determines if this quaternion is equal to the given quaternion, using a given threshold for determining if two numbers are equal.

Parameters:
other - The other quaternion.
effectiveZero - The effective zero value for performing the fuzzy equality. Typically, this is a number close to zero.
Returns:
True if the two are equal; otherwise, false.

getW

double getW()
Gets the w component of the quaternion.

Returns:
The w component of the quaternion.

setW

void setW(double w)
Sets the w component of the quaternion.

Parameters:
w - The w component of the quaternion.

getX

double getX()
Gets the x component of the quaternion.

Returns:
The x component of the quaternion.

setX

void setX(double x)
Sets the x component of the quaternion.

Parameters:
x - The x component of the quaternion.

getY

double getY()
Gets the y component of the quaternion.

Returns:
The y component of the quaternion.

setY

void setY(double y)
Sets the y component of the quaternion.

Parameters:
y - The y component of the quaternion.

getZ

double getZ()
Gets the z component of the quaternion.

Returns:
The z component of the quaternion.

setZ

void setZ(double z)
Sets the z component of the quaternion.

Parameters:
z - The z component of the quaternion.

setWXYZ

void setWXYZ(double w,
             double x,
             double y,
             double z)
Sets all of the elements of the quaternion in w-x-y-z order.

Parameters:
w - The w component of the quaternion.
x - The x component of the quaternion.
y - The y component of the quaternion.
z - The z component of the quaternion.

setXYZW

void setXYZW(double x,
             double y,
             double z,
             double w)
Sets all of the elements of the quaternion in x-y-z-w order.

Parameters:
x - The x component of the quaternion.
y - The y component of the quaternion.
z - The z component of the quaternion.
w - The w component of the quaternion.