Package org.lwjgl.util.vector
Class Quaternion
java.lang.Object
org.lwjgl.util.vector.Vector
org.lwjgl.util.vector.Quaternion
- All Implemented Interfaces:
Serializable,ReadableVector,ReadableVector2f,ReadableVector3f,ReadableVector4f
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floatdot(Quaternion left, Quaternion right) The dot product of two quaternionsfloatgetW()final floatgetX()final floatgetY()floatgetZ()floatload(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.negate()Calculate the conjugate of this quaternionnegate(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 onenormalise(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.scale(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) set(ReadableVector4f src) Load from another Vector4ffinal voidSets the value of this quaternion to the equivalent rotation of the Axis-Angle argument.final QuaternionSets 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.final QuaternionSets 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.Set this quaternion to the multiplication identity.static QuaternionSet the given quaternion to the multiplication identity.voidsetW(float w) Set Wfinal voidsetX(float x) Set Xfinal voidsetY(float y) Set YvoidsetZ(float z) Set Zstore(FloatBuffer buf) Store this vector in a FloatBuffertoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.lwjgl.util.vector.ReadableVector
length
-
Field Details
-
x
public float x -
y
public float y -
z
public float z -
w
public float w
-
-
Constructor Details
-
Quaternion
public Quaternion()C'tor. The quaternion will be initialized to the identity. -
Quaternion
C'tor- Parameters:
src-
-
Quaternion
public Quaternion(float x, float y, float z, float w) C'tor
-
-
Method Details
-
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
Load from another Vector4f- Parameters:
src- The source vector- Returns:
- this
-
setIdentity
Set this quaternion to the multiplication identity.- Returns:
- this
-
setIdentity
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
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
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
The dot product of two quaternions- Parameters:
left- The LHS quatright- The RHS quat- Returns:
- left dot right
-
negate
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
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
Calculate the conjugate of this quaternion -
load
Description copied from class:VectorLoad this vector from a FloatBuffer -
scale
Description copied from class:VectorScale this vector -
scale
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
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
-
mul
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
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
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
Sets the value of this quaternion using the rotational component of the passed matrix.- Parameters:
m- The matrix- Returns:
- this
-
setFromMatrix
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
Sets the value of this quaternion using the rotational component of the passed matrix.- Parameters:
m- The source matrix
-
setFromMatrix
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
-