|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.jinx.math.Quaternion
public class Quaternion
Quaternion is effectively, a 4 element vector with special functionality.
This class is most often used for storing rotation data. This class is built
from a Vector instance and a float for the additional w coordinate. The
Vector holds data describing the axis of rotation and the w component holds
the magnitude of the rotation.
Quaternions have other uses, however.
Field Summary | |
---|---|
static Quaternion |
zero
|
Constructor Summary | |
---|---|
Quaternion()
Constructs a Quaternion with all zero components. |
|
Quaternion(float[] vec)
Constructs a new Quaternion with the given W/X/Y/Z coordinates. |
|
Quaternion(float x,
float y,
float z,
float w)
Constructs a new Quaternion with the given W/X/Y/Z coordinates. |
|
Quaternion(java.lang.String s)
Constructs a new Quaternion by parsing the given String. |
|
Quaternion(Vector v,
float w)
Constructs a new Quaternion from v and w. |
Method Summary | |
---|---|
Quaternion |
add(float n)
|
Quaternion |
add(Quaternion q)
|
Quaternion |
conjugate()
|
Quaternion |
divide(float n)
|
Quaternion |
divide(Quaternion q)
|
boolean |
equals(java.lang.Object obj)
|
void |
fillFloatArray(float[] fa)
Fills a length 4 float array with the values for getX(), getY(), getZ() and getW(). |
Vector |
getV()
|
float |
getW()
Provides the W component. |
float |
getX()
Provides the X coordinate. |
float |
getY()
Provides the Y coordinate. |
float |
getZ()
Provides the Z coordinate. |
int |
hashCode()
Returns the hash code for this Quaternion. |
Quaternion |
invert()
|
float |
magnitude()
|
Quaternion |
multiply(float n)
|
Quaternion |
multiply(Quaternion q2)
|
Quaternion |
normalize()
|
Quaternion |
subtract(float n)
|
Quaternion |
subtract(Quaternion q)
|
float[] |
toFloatArray()
Converts this Quaternion to a float array. |
java.lang.String |
toString()
Provides a String representation of this Vector. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Quaternion zero
Constructor Detail |
---|
public Quaternion()
public Quaternion(float x, float y, float z, float w)
w
- the W coordinate.x
- the X coordinate.y
- the Y coordinate.z
- the Z coordinate.public Quaternion(float[] vec)
vec
- the coordinates in an array.public Quaternion(Vector v, float w)
v
- the Vector component for this Quaternion.w
- the W component for this Quaternion.public Quaternion(java.lang.String s)
s
- the String to parse.Method Detail |
---|
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public float getW()
public Vector getV()
public float getX()
public float getY()
public float getZ()
public Quaternion add(float n)
public Quaternion add(Quaternion q)
public Quaternion subtract(float n)
public Quaternion subtract(Quaternion q)
public Quaternion multiply(float n)
public Quaternion multiply(Quaternion q2)
public Quaternion conjugate()
public Quaternion invert()
public Quaternion divide(float n)
public Quaternion divide(Quaternion q)
public float magnitude()
public Quaternion normalize()
public float[] toFloatArray()
public void fillFloatArray(float[] fa)
fa
- the float array to fill.
java.lang.IllegalArgumentException
- if fa is not length 4.public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |