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 float
dot(Quaternion left, Quaternion right)
The dot product of two quaternionsfloat
getW()
float
getX()
float
getY()
float
getZ()
float
lengthSquared()
Vector
load(FloatBuffer buf)
Load this vector from a FloatBufferstatic 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).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.Vector
negate()
Calculate the conjugate of this quaternionQuaternion
negate(Quaternion dest)
Calculate the conjugate of this quaternion and put it into the given onestatic Quaternion
negate(Quaternion src, Quaternion dest)
Calculate the conjugate of this quaternion and put it into the given oneQuaternion
normalise(Quaternion dest)
Normalise this quaternion and place the result in another quaternion.static Quaternion
normalise(Quaternion src, Quaternion dest)
Normalise the source quaternion and place the result in another quaternion.Vector
scale(float scale)
Scale this vectorstatic Quaternion
scale(float scale, Quaternion src, Quaternion dest)
Scale the source quaternion by scale and put the result in the destinationvoid
set(float x, float y)
void
set(float x, float y, float z)
void
set(float x, float y, float z, float w)
Quaternion
set(ReadableVector4f src)
Load from another Vector4fvoid
setFromAxisAngle(Vector4f a1)
Sets the value of this quaternion to the equivalent rotation of the Axis-Angle argument.Quaternion
setFromMatrix(Matrix3f m)
Sets the value of this quaternion using the rotational component of the passed matrix.static Quaternion
setFromMatrix(Matrix3f m, Quaternion q)
Sets the value of the source quaternion using the rotational component of the passed matrix.Quaternion
setFromMatrix(Matrix4f m)
Sets the value of this quaternion using the rotational component of the passed matrix.static Quaternion
setFromMatrix(Matrix4f m, Quaternion q)
Sets the value of the source quaternion using the rotational component of the passed matrix.Quaternion
setIdentity()
Set this quaternion to the multiplication identity.static Quaternion
setIdentity(Quaternion q)
Set the given quaternion to the multiplication identity.void
setW(float w)
Set Wvoid
setX(float x)
Set Xvoid
setY(float y)
Set Yvoid
setZ(float z)
Set ZVector
store(FloatBuffer buf)
Store this vector in a FloatBufferjava.lang.String
toString()
-
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:
lengthSquared
in interfaceReadableVector
- Specified by:
lengthSquared
in 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:Vector
Load 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:Vector
Store this vector in a FloatBuffer- Specified by:
store
in interfaceReadableVector
- Specified by:
store
in classVector
- Parameters:
buf
- The buffer to store it in, at the current position- Returns:
- this
-
getX
public final float getX()
- Specified by:
getX
in interfaceReadableVector2f
- Returns:
- x
-
getY
public final float getY()
- Specified by:
getY
in 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:
getZ
in interfaceReadableVector3f
- Returns:
- z
-
setW
public void setW(float w)
Set W- Parameters:
w
-
-
getW
public float getW()
- Specified by:
getW
in interfaceReadableVector4f
- Returns:
- w
-
toString
public java.lang.String toString()
- Overrides:
toString
in 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
-
-