Class Quaternion
- java.lang.Object
-
- net.lax1dude.eaglercraft.v1_8.vector.Vector
-
- net.lax1dude.eaglercraft.v1_8.vector.Quaternion
-
- All Implemented Interfaces:
java.io.Serializable,ReadableVector,ReadableVector2f,ReadableVector3f,ReadableVector4f
public class Quaternion extends Vector implements ReadableVector4f
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Quaternion()C'tor.Quaternion(float x, float y, float z, float w)C'torQuaternion(ReadableVector4f src)C'tor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static floatdot(Quaternion left, Quaternion right)The dot product of two quaternionsfloatgetW()floatgetX()floatgetY()floatgetZ()floatlengthSquared()Vectorload(FloatBuffer buf)Load this vector from a FloatBufferstatic Quaternionmul(Quaternion left, Quaternion right, Quaternion dest)Sets the value of this quaternion to the quaternion product of quaternions left and right (this = left * right).static QuaternionmulInverse(Quaternion left, Quaternion right, Quaternion dest)Multiplies quaternion left by the inverse of quaternion right and places the value into this quaternion.Vectornegate()Calculate the conjugate of this quaternionQuaternionnegate(Quaternion dest)Calculate the conjugate of this quaternion and put it into the given onestatic Quaternionnegate(Quaternion src, Quaternion dest)Calculate the conjugate of this quaternion and put it into the given oneQuaternionnormalise(Quaternion dest)Normalise this quaternion and place the result in another quaternion.static Quaternionnormalise(Quaternion src, Quaternion dest)Normalise the source quaternion and place the result in another quaternion.Vectorscale(float scale)Scale this vectorstatic Quaternionscale(float scale, Quaternion src, Quaternion dest)Scale the source quaternion by scale and put the result in the destinationvoidset(float x, float y)voidset(float x, float y, float z)voidset(float x, float y, float z, float w)Quaternionset(ReadableVector4f src)Load from another Vector4fvoidsetFromAxisAngle(Vector4f a1)Sets the value of this quaternion to the equivalent rotation of the Axis-Angle argument.QuaternionsetFromMatrix(Matrix3f m)Sets the value of this quaternion using the rotational component of the passed matrix.static QuaternionsetFromMatrix(Matrix3f m, Quaternion q)Sets the value of the source quaternion using the rotational component of the passed matrix.QuaternionsetFromMatrix(Matrix4f m)Sets the value of this quaternion using the rotational component of the passed matrix.static QuaternionsetFromMatrix(Matrix4f m, Quaternion q)Sets the value of the source quaternion using the rotational component of the passed matrix.QuaternionsetIdentity()Set this quaternion to the multiplication identity.static QuaternionsetIdentity(Quaternion q)Set the given quaternion to the multiplication identity.voidsetW(float w)Set WvoidsetX(float x)Set XvoidsetY(float y)Set YvoidsetZ(float z)Set ZVectorstore(FloatBuffer buf)Store this vector in a FloatBufferjava.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.lax1dude.eaglercraft.v1_8.vector.ReadableVector
length
-
-
-
-
Constructor Detail
-
Quaternion
public Quaternion()
C'tor. The quaternion will be initialized to the identity.
-
Quaternion
public Quaternion(ReadableVector4f src)
C'tor- Parameters:
src-
-
Quaternion
public Quaternion(float x, float y, float z, float w)C'tor
-
-
Method Detail
-
set
public void set(float x, float y)
-
set
public void set(float x, float y, float z)
-
set
public void set(float x, float y, float z, float w)
-
set
public Quaternion set(ReadableVector4f src)
Load from another Vector4f- Parameters:
src- The source vector- Returns:
- this
-
setIdentity
public Quaternion setIdentity()
Set this quaternion to the multiplication identity.- Returns:
- this
-
setIdentity
public static Quaternion setIdentity(Quaternion q)
Set the given quaternion to the multiplication identity.- Parameters:
q- The quaternion- Returns:
- q
-
lengthSquared
public float lengthSquared()
- Specified by:
lengthSquaredin interfaceReadableVector- Specified by:
lengthSquaredin classVector- Returns:
- the length squared of the quaternion
-
normalise
public static Quaternion normalise(Quaternion src, Quaternion dest)
Normalise the source quaternion and place the result in another quaternion.- Parameters:
src- The source quaterniondest- The destination quaternion, or null if a new quaternion is to be created- Returns:
- The normalised quaternion
-
normalise
public Quaternion normalise(Quaternion dest)
Normalise this quaternion and place the result in another quaternion.- Parameters:
dest- The destination quaternion, or null if a new quaternion is to be created- Returns:
- the normalised quaternion
-
dot
public static float dot(Quaternion left, Quaternion right)
The dot product of two quaternions- Parameters:
left- The LHS quatright- The RHS quat- Returns:
- left dot right
-
negate
public Quaternion negate(Quaternion dest)
Calculate the conjugate of this quaternion and put it into the given one- Parameters:
dest- The quaternion which should be set to the conjugate of this quaternion
-
negate
public static Quaternion negate(Quaternion src, Quaternion dest)
Calculate the conjugate of this quaternion and put it into the given one- Parameters:
src- The source quaterniondest- The quaternion which should be set to the conjugate of this quaternion
-
negate
public Vector negate()
Calculate the conjugate of this quaternion
-
load
public Vector load(FloatBuffer buf)
Description copied from class:VectorLoad this vector from a FloatBuffer
-
scale
public static Quaternion scale(float scale, Quaternion src, Quaternion dest)
Scale the source quaternion by scale and put the result in the destination- Parameters:
scale- The amount to scale bysrc- The source quaterniondest- The destination quaternion, or null if a new quaternion is to be created- Returns:
- The scaled quaternion
-
store
public Vector store(FloatBuffer buf)
Description copied from class:VectorStore this vector in a FloatBuffer- Specified by:
storein interfaceReadableVector- Specified by:
storein classVector- Parameters:
buf- The buffer to store it in, at the current position- Returns:
- this
-
getX
public final float getX()
- Specified by:
getXin interfaceReadableVector2f- Returns:
- x
-
getY
public final float getY()
- Specified by:
getYin interfaceReadableVector2f- Returns:
- y
-
setX
public final void setX(float x)
Set X- Parameters:
x-
-
setY
public final void setY(float y)
Set Y- Parameters:
y-
-
setZ
public void setZ(float z)
Set Z- Parameters:
z-
-
getZ
public float getZ()
- Specified by:
getZin interfaceReadableVector3f- Returns:
- z
-
setW
public void setW(float w)
Set W- Parameters:
w-
-
getW
public float getW()
- Specified by:
getWin interfaceReadableVector4f- Returns:
- w
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
mul
public static Quaternion mul(Quaternion left, Quaternion right, Quaternion dest)
Sets the value of this quaternion to the quaternion product of quaternions left and right (this = left * right). Note that this is safe for aliasing (e.g. this can be left or right).- Parameters:
left- the first quaternionright- the second quaternion
-
mulInverse
public static Quaternion mulInverse(Quaternion left, Quaternion right, Quaternion dest)
Multiplies quaternion left by the inverse of quaternion right and places the value into this quaternion. The value of both argument quaternions is preservered (this = left * right^-1).- Parameters:
left- the left quaternionright- the right quaternion
-
setFromAxisAngle
public final void setFromAxisAngle(Vector4f a1)
Sets the value of this quaternion to the equivalent rotation of the Axis-Angle argument.- Parameters:
a1- the axis-angle: (x,y,z) is the axis and w is the angle
-
setFromMatrix
public final Quaternion setFromMatrix(Matrix4f m)
Sets the value of this quaternion using the rotational component of the passed matrix.- Parameters:
m- The matrix- Returns:
- this
-
setFromMatrix
public static Quaternion setFromMatrix(Matrix4f m, Quaternion q)
Sets the value of the source quaternion using the rotational component of the passed matrix.- Parameters:
m- The source matrixq- The destination quaternion, or null if a new quaternion is to be created- Returns:
- q
-
setFromMatrix
public final Quaternion setFromMatrix(Matrix3f m)
Sets the value of this quaternion using the rotational component of the passed matrix.- Parameters:
m- The source matrix
-
setFromMatrix
public static Quaternion setFromMatrix(Matrix3f m, Quaternion q)
Sets the value of the source quaternion using the rotational component of the passed matrix.- Parameters:
m- The source matrixq- The destination quaternion, or null if a new quaternion is to be created- Returns:
- q
-
-