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 float
dot
(Quaternion left, Quaternion right) The dot product of two quaternionsfloat
getW()
final float
getX()
final float
getY()
float
getZ()
float
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.negate()
Calculate the conjugate of this quaternionnegate
(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 onenormalise
(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.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) set
(ReadableVector4f src) Load from another Vector4ffinal void
Sets the value of this quaternion to the equivalent rotation of the Axis-Angle argument.final Quaternion
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.final Quaternion
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.Set this quaternion to the multiplication identity.static Quaternion
Set the given quaternion to the multiplication identity.void
setW
(float w) Set Wfinal void
setX
(float x) Set Xfinal void
setY
(float y) Set Yvoid
setZ
(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, wait
Methods 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:
lengthSquared
in interfaceReadableVector
- Specified by:
lengthSquared
in 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:Vector
Load this vector from a FloatBuffer -
scale
Description copied from class:Vector
Scale 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: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
-
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
-