quicktime.qd3d.math
Class Quaternion

java.lang.Object
  |
  +--quicktime.util.QTByteObject
        |
        +--quicktime.qd3d.math.Quaternion
All Implemented Interfaces:
java.lang.Cloneable, quicktime.jdirect.InterfaceLib, quicktime.jdirect.PrimitivesLib, quicktime.jdirect.QuickDraw3DLib, quicktime.jdirect.QuickTimeLib, java.io.Serializable, quicktime.jdirect.SharedLibrary, com.apple.jdirect.SharedLibrary

public final class Quaternion
extends QTByteObject
implements quicktime.jdirect.QuickTimeLib, quicktime.jdirect.QuickDraw3DLib, java.lang.Cloneable

Quaternion A quadruple of floating-point numbers that obeys the laws of quaternion arithmetic. A Quaternion transform will rotate and twist an object according to the mathematical properties of quaternions. Refer to TQ3Quaternion in QuickDraw3d

See Also:
Serialized Form

Field Summary
static int kNativeSize
          This is the size (the number of bytes) that are required for this class
 
Fields inherited from interface quicktime.jdirect.QuickTimeLib
JDirect_MacOSX, libraryInstance, name
 
Fields inherited from interface quicktime.jdirect.QuickDraw3DLib
libraryInstance
 
Constructor Summary
Quaternion()
          Creates a Quaternion object set to the identity.
Quaternion(float w, float x, float y, float z)
          Creates a Quaternion object containing given data.
 
Method Summary
 java.lang.Object clone()
          Returns a copy of this class.
 Quaternion copy()
          Returns a copy of the quaternion.
 float dot(Quaternion q2)
          Returns the dot product of two quaternions, this and q2.
static EndianDescriptor getEndianDescriptor()
          Returns the EndianDescriptor for this class.
 float getW()
          returns the w value
 float getX()
          returns the position in the x direction
 float getY()
          returns the position in the y direction
 float getZ()
          returns the position in the z direction
 Quaternion interpolateFast(Quaternion q2, float t)
          Return a a quaternion that is a fast interpolation between the this and the specified quaternion.
 Quaternion interpolateLinear(Quaternion q2, float t)
          Return a a quaternion that is a linear interpolation between the this and the specified quaternion.
 Quaternion invert()
          Returns the inverse of the quaternion.
 boolean isIdentity()
          Returns rue if the quaternion is an identity quaternion.
 Quaternion matchReflection(Quaternion q2)
          Returns a quaternion that is either identical to the quaternion specified by the q1 parameter or is the negative of q1, depending on whether q1 or its negative matches the orientation of the quaternion specified by the q2 parameter.
 Quaternion multiply(Quaternion q2)
          Returns the product of the two quaternions, this and q2.
 Quaternion normalize()
          Returns a normalized the quaternion.
 void setIdentity()
          Sets the Quaternion to the identity quaternion.
 void setMatrix(Matrix4x4 matrix)
          Sets a quaternion that has the same transformational properties as the matrix specified by the matrix parameter.
 void setRotateAboutAxis(Vector3D axis, float angle)
          Sets a a rotate-about-axis quaternion that rotates an object by the angle angle around the axis specified by the axis parameter.
 void setRotateVectorToVector(Vector3D v1, Vector3D v2)
          Sets a rotational quaternion that rotates objects around the origin in such a way that the transformed vector v1 matches the vector v2.
 void setRotateX(float angle)
          Sets a rotational quaternion that rotates an object by the specified angle around the x axis.
 void setRotateXYZ(float xAngle, float yAngle, float zAngle)
          Sets a rotational quaternion that rotates an object by the specified angles around their specified axis.
 void setRotateY(float angle)
          Sets a rotational quaternion that rotates an object by the specified angle around the y axis.
 void setRotateZ(float angle)
          Sets a rotational quaternion that rotates an object by the specified angle around the x axis.
 void setW(float w)
          sets the w value
 void setX(float x)
          sets the position in the x direction
 void setY(float y)
          sets the position in the y direction
 void setZ(float z)
          sets the position in the z direction
 
Methods inherited from class quicktime.util.QTByteObject
equals, fromArray, getBytes, getSize, toString
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

kNativeSize

public static final int kNativeSize
This is the size (the number of bytes) that are required for this class
Constructor Detail

Quaternion

public Quaternion()
Creates a Quaternion object set to the identity.

QuickDraw3D::Q3Quaternion_SetIdentity


Quaternion

public Quaternion(float w,
                  float x,
                  float y,
                  float z)
Creates a Quaternion object containing given data.
Parameters:
w - The final w value.
x - The final x position.
y - The final y position.
z - The final z position.
Method Detail

getEndianDescriptor

public static final EndianDescriptor getEndianDescriptor()
Returns the EndianDescriptor for this class.
Returns:
an EndianDescriptor

getW

public float getW()
returns the w value

getX

public float getX()
returns the position in the x direction

getY

public float getY()
returns the position in the y direction

getZ

public float getZ()
returns the position in the z direction

setW

public void setW(float w)
sets the w value

setX

public void setX(float x)
sets the position in the x direction

setY

public void setY(float y)
sets the position in the y direction

setZ

public void setZ(float z)
sets the position in the z direction

copy

public Quaternion copy()
Returns a copy of the quaternion.

QuickDraw3D::Q3Quaternion_Copy

Returns:
a copy of quaternion.

setIdentity

public void setIdentity()
Sets the Quaternion to the identity quaternion.

QuickDraw3D::Q3Quaternion_SetIdentity


isIdentity

public boolean isIdentity()
Returns rue if the quaternion is an identity quaternion.

QuickDraw3D::Q3Quaternion_IsIdentity

Returns:
true if the quaternion is an identity quaternion

invert

public Quaternion invert()
Returns the inverse of the quaternion.

QuickDraw3D::Q3Quaternion_Invert

Returns:
the invert quaternion

multiply

public Quaternion multiply(Quaternion q2)
Returns the product of the two quaternions, this and q2.

QuickDraw3D::Q3Quaternion_Multiply

Parameters:
q2 - a quaternion
Returns:
the product

normalize

public Quaternion normalize()
Returns a normalized the quaternion.

QuickDraw3D::Q3Quaternion_Normalize

Returns:
the normalized quaternion

dot

public float dot(Quaternion q2)
Returns the dot product of two quaternions, this and q2.

QuickDraw3D::Q3Quaternion_Dot

Parameters:
q2 - A quaternion.
Returns:
the dot product

setRotateAboutAxis

public void setRotateAboutAxis(Vector3D axis,
                               float angle)
Sets a a rotate-about-axis quaternion that rotates an object by the angle angle around the axis specified by the axis parameter.

QuickDraw3D::Q3Quaternion_SetRotateAboutAxis

Parameters:
axis - The desired axis of rotation.
angle - The desired angle of rotation, in radians.

setRotateX

public void setRotateX(float angle)
Sets a rotational quaternion that rotates an object by the specified angle around the x axis.

QuickDraw3D::Q3Quaternion_SetRotate_X

Parameters:
angle - The desired angle of rotation around the x coordinate axis, in radians.

setRotateY

public void setRotateY(float angle)
Sets a rotational quaternion that rotates an object by the specified angle around the y axis.

QuickDraw3D::Q3Quaternion_SetRotate_Y

Parameters:
angle - The desired angle of rotation around the y coordinate axis, in radians.

setRotateZ

public void setRotateZ(float angle)
Sets a rotational quaternion that rotates an object by the specified angle around the x axis.

QuickDraw3D::Q3Quaternion_SetRotate_Z

Parameters:
angle - The desired angle of rotation around the z coordinate axis, in radians.

setRotateXYZ

public void setRotateXYZ(float xAngle,
                         float yAngle,
                         float zAngle)
Sets a rotational quaternion that rotates an object by the specified angles around their specified axis.

QuickDraw3D::Q3Quaternion_SetRotate_XYZ

Parameters:
xAngle - The desired angle of rotation around the x coordinate axis, in radians.
yAngle - The desired angle of rotation around the y coordinate axis, in radians.
zAngle - The desired angle of rotation around the z coordinate axis, in radians.

setMatrix

public void setMatrix(Matrix4x4 matrix)
Sets a quaternion that has the same transformational properties as the matrix specified by the matrix parameter.

QuickDraw3D::Q3Quaternion_SetMatrix

Parameters:
matrix - A 4-by-by matrix.

setRotateVectorToVector

public void setRotateVectorToVector(Vector3D v1,
                                    Vector3D v2)
Sets a rotational quaternion that rotates objects around the origin in such a way that the transformed vector v1 matches the vector v2. Both v1 and v2 should be normalized.

QuickDraw3D::Q3Quaternion_SetRotateVectorToVector

Parameters:
v1 - A three-dimensional vector.
v2 - A three-dimensional vector.

matchReflection

public Quaternion matchReflection(Quaternion q2)
Returns a quaternion that is either identical to the quaternion specified by the q1 parameter or is the negative of q1, depending on whether q1 or its negative matches the orientation of the quaternion specified by the q2 parameter.

QuickDraw3D::Q3Quaternion_MatchReflection

Parameters:
q2 - A quaternion.
Returns:
a quaternion that is either q1 or the negative of q1, and that matches the orientation of q2.

interpolateFast

public Quaternion interpolateFast(Quaternion q2,
                                  float t)
Return a a quaternion that is a fast interpolation between the this and the specified quaternion.

QuickDraw3D::Q3Quaternion_InterpolateFast

Parameters:
q2 - A quaternion.
t - An interpolation factor. This parameter should contain a value between 0.0 and 1.0.
Returns:
a quaternion

interpolateLinear

public Quaternion interpolateLinear(Quaternion q2,
                                    float t)
Return a a quaternion that is a linear interpolation between the this and the specified quaternion.

QuickDraw3D::Q3Quaternion_InterpolateLinear

Parameters:
q2 - A quaternion.
t - An interpolation factor. This parameter should contain a value between 0.0 and 1.0.
Returns:
a quaternion

clone

public java.lang.Object clone()
Returns a copy of this class.