Version 1.5APIs subject to change!

multiverse.server.math
Class Quaternion

java.lang.Object
  extended by multiverse.server.math.Quaternion
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable

public class Quaternion
extends java.lang.Object
implements java.io.Externalizable, java.lang.Cloneable

this object is not thread safe

See Also:
Serialized Form

Field Summary
static float epsilon
           
static Quaternion Identity
           
 
Constructor Summary
Quaternion()
          no args constructor sets w to 1.0, all others 0
Quaternion(float x, float y, float z, float w)
           
 
Method Summary
 java.lang.Object clone()
           
 boolean equals(Quaternion q)
           
static Quaternion fromAngleAxis(double angle, MVVector axis)
          Create a quaternion from a supplied angle and axis
static Quaternion fromAngleAxisDegrees(double angle, MVVector axis)
          Create a quaternion from a supplied angle and axis
static Quaternion fromVectorRotation(MVVector a, MVVector b)
          Create a new quaternion that will rotate vector a into vector b about their mutually perpendicular axis.
 double getAngleAxis(MVVector axis)
          Get the axis of rotation and the angle for this quaternion
 double getAngleAxisDegrees(MVVector axis)
          Get the axis of rotation and the angle for this quaternion
 float getW()
           
 float getX()
           
 float getY()
           
 float getZ()
           
static MVVector multiply(Quaternion quat, MVVector vector)
           
static Quaternion multiply(Quaternion left, Quaternion right)
          Multiply two quaternions
static Quaternion parseQuaternion(java.lang.String s)
           
 void readExternal(java.io.ObjectInput in)
           
 void setW(float w)
           
 void setX(float x)
           
 void setY(float y)
           
 void setZ(float z)
           
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Identity

public static final Quaternion Identity

epsilon

public static float epsilon
Constructor Detail

Quaternion

public Quaternion()
no args constructor sets w to 1.0, all others 0


Quaternion

public Quaternion(float x,
                  float y,
                  float z,
                  float w)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

parseQuaternion

public static Quaternion parseQuaternion(java.lang.String s)

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

equals

public boolean equals(Quaternion q)

getX

public float getX()

getY

public float getY()

getZ

public float getZ()

getW

public float getW()

setX

public void setX(float x)

setY

public void setY(float y)

setZ

public void setZ(float z)

setW

public void setW(float w)

fromAngleAxis

public static Quaternion fromAngleAxis(double angle,
                                       MVVector axis)
Create a quaternion from a supplied angle and axis

Parameters:
angle - angle in radians
axis - axis vector about which to rotate
Returns:
a quaternion based on the axis and angle

fromAngleAxisDegrees

public static Quaternion fromAngleAxisDegrees(double angle,
                                              MVVector axis)
Create a quaternion from a supplied angle and axis

Parameters:
angle - angle in degrees
axis - axis vector about which to rotate
Returns:
a quaternion based on the axis and angle

getAngleAxisDegrees

public double getAngleAxisDegrees(MVVector axis)
Get the axis of rotation and the angle for this quaternion

Parameters:
axis - reference to axis vector which will be populated with axis of rotation.
Returns:
angle in degrees

getAngleAxis

public double getAngleAxis(MVVector axis)
Get the axis of rotation and the angle for this quaternion

Parameters:
axis - reference to axis vector which will be populated with axis of rotation.
Returns:
angle in degrees

fromVectorRotation

public static Quaternion fromVectorRotation(MVVector a,
                                            MVVector b)
Create a new quaternion that will rotate vector a into vector b about their mutually perpendicular axis.

Parameters:
a - starting facing
b - ending facing

multiply

public static Quaternion multiply(Quaternion left,
                                  Quaternion right)
Multiply two quaternions

Parameters:
left - the quaternion on the left
right - the quaternion on the right
Returns:
the product of left * right

multiply

public static MVVector multiply(Quaternion quat,
                                MVVector vector)

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException


Copyright © 2008 The Multiverse Network, Inc.