Class Quaternionf
- All Implemented Interfaces:
Externalizable
,Serializable
,Cloneable
,Quaternionfc
- Author:
- Richard Greenlees, Kai Burjack
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate a newQuaternionf
and initialize it with(x=0, y=0, z=0, w=1)
, where(x, y, z)
is the vector part of the quaternion andw
is the real/scalar part.Quaternionf
(double x, double y, double z, double w) Create a newQuaternionf
and initialize its components to the given values.Quaternionf
(float x, float y, float z, float w) Create a newQuaternionf
and initialize its components to the given values.Quaternionf
(AxisAngle4d axisAngle) Create a newQuaterniond
which represents the rotation of the givenAxisAngle4d
.Quaternionf
(AxisAngle4f axisAngle) Create a newQuaternionf
which represents the rotation of the givenAxisAngle4f
.Quaternionf
(Quaterniondc source) Create a newQuaternionf
and initialize its components to the same values as the givenQuaterniondc
.Quaternionf
(Quaternionfc source) Create a newQuaternionf
and initialize its components to the same values as the givenQuaternionfc
. -
Method Summary
Modifier and TypeMethodDescriptionadd
(float x, float y, float z, float w) Add the quaternion(x, y, z, w)
to this quaternion.add
(float x, float y, float z, float w, Quaternionf dest) Add the quaternion(x, y, z, w)
to this quaternion and store the result indest
.add
(Quaternionfc q2) Addq2
to this quaternion.add
(Quaternionfc q2, Quaternionf dest) Addq2
to this quaternion and store the result indest
.float
angle()
Return the angle in radians represented by this normalized quaternion rotation.clone()
Conjugate this quaternion.conjugate
(Quaternionf dest) Conjugate this quaternion and store the result indest
.Conjugatethis
by the given quaternionq
by computingq * this * q^-1
.conjugateBy
(Quaternionfc q, Quaternionf dest) Conjugatethis
by the given quaternionq
by computingq * this * q^-1
and store the result intodest
.difference
(Quaternionf other) Compute the difference betweenthis
and theother
quaternion and store the result inthis
.difference
(Quaternionfc other, Quaternionf dest) Compute the difference betweenthis
and theother
quaternion and store the result indest
.div
(Quaternionfc b) Dividethis
quaternion byb
.div
(Quaternionfc b, Quaternionf dest) Dividethis
quaternion byb
and store the result indest
.float
dot
(Quaternionf otherQuat) Return the dot of this quaternion andotherQuat
.boolean
equals
(float x, float y, float z, float w) boolean
boolean
equals
(Quaternionfc q, float delta) Compare the quaternion components ofthis
quaternion with the given quaternion using the givendelta
and return whether all of them are equal within a maximum difference ofdelta
.fromAxisAngleDeg
(float axisX, float axisY, float axisZ, float angle) Set this quaternion to be a representation of the supplied axis and angle (in degrees).fromAxisAngleDeg
(Vector3fc axis, float angle) Set this quaternion to be a representation of the supplied axis and angle (in degrees).fromAxisAngleRad
(float axisX, float axisY, float axisZ, float angle) Set this quaternion to be a representation of the supplied axis and angle (in radians).fromAxisAngleRad
(Vector3fc axis, float angle) Set this quaternion to be a representation of the supplied axis and angle (in radians).get
(AxisAngle4d dest) Set the givenAxisAngle4d
to represent the rotation ofthis
quaternion.get
(AxisAngle4f dest) Set the givenAxisAngle4f
to represent the rotation ofthis
quaternion.Set the given destination matrix to the rotation represented bythis
.Set the given destination matrix to the rotation represented bythis
.Set the given destination matrix to the rotation represented bythis
.Set the given destination matrix to the rotation represented bythis
.get
(Matrix4x3d dest) Set the given destination matrix to the rotation represented bythis
.get
(Matrix4x3f dest) Set the given destination matrix to the rotation represented bythis
.get
(Quaterniond dest) Set the givenQuaterniond
to the values ofthis
.get
(Quaternionf dest) Set the givenQuaternionf
to the values ofthis
.getAsMatrix3f
(ByteBuffer dest) Store the 3x3 float matrix representation ofthis
quaternion in column-major order into the givenByteBuffer
.getAsMatrix3f
(FloatBuffer dest) Store the 3x3 float matrix representation ofthis
quaternion in column-major order into the givenFloatBuffer
.getAsMatrix4f
(ByteBuffer dest) Store the 4x4 float matrix representation ofthis
quaternion in column-major order into the givenByteBuffer
.getAsMatrix4f
(FloatBuffer dest) Store the 4x4 float matrix representation ofthis
quaternion in column-major order into the givenFloatBuffer
.getAsMatrix4x3f
(ByteBuffer dest) Store the 4x3 float matrix representation ofthis
quaternion in column-major order into the givenByteBuffer
.getAsMatrix4x3f
(FloatBuffer dest) Store the 4x3 float matrix representation ofthis
quaternion in column-major order into the givenFloatBuffer
.getEulerAnglesXYZ
(Vector3f eulerAngles) Get the euler angles in radians in rotation sequenceXYZ
of this quaternion and store them in the provided parametereulerAngles
.getEulerAnglesYXZ
(Vector3f eulerAngles) Get the euler angles in radians in rotation sequenceYXZ
of this quaternion and store them in the provided parametereulerAngles
.getEulerAnglesZXY
(Vector3f eulerAngles) Get the euler angles in radians in rotation sequenceZXY
of this quaternion and store them in the provided parametereulerAngles
.getEulerAnglesZYX
(Vector3f eulerAngles) Get the euler angles in radians in rotation sequenceZYX
of this quaternion and store them in the provided parametereulerAngles
.int
hashCode()
identity()
Set this quaternion to the identity.integrate
(float dt, float vx, float vy, float vz) Integrate the rotation given by the angular velocity(vx, vy, vz)
around the x, y and z axis, respectively, with respect to the given elapsed time deltadt
and add the differentiate rotation to the rotation represented by this quaternion.integrate
(float dt, float vx, float vy, float vz, Quaternionf dest) Integrate the rotation given by the angular velocity(vx, vy, vz)
around the x, y and z axis, respectively, with respect to the given elapsed time deltadt
and add the differentiate rotation to the rotation represented by this quaternion and store the result intodest
.invert()
Invert this quaternion andnormalize
it.invert
(Quaternionf dest) Invert this quaternion and store thenormalized
result indest
.boolean
isFinite()
float
Return the square of the length of this quaternion.lookAlong
(float dirX, float dirY, float dirZ, float upX, float upY, float upZ) Apply a rotation to this quaternion that maps the given direction to the positive Z axis.lookAlong
(float dirX, float dirY, float dirZ, float upX, float upY, float upZ, Quaternionf dest) Apply a rotation to this quaternion that maps the given direction to the positive Z axis, and store the result indest
.Apply a rotation to this quaternion that maps the given direction to the positive Z axis.lookAlong
(Vector3fc dir, Vector3fc up, Quaternionf dest) Apply a rotation to this quaternion that maps the given direction to the positive Z axis, and store the result indest
.mul
(float f) Multiply this quaternion by the given scalar.mul
(float qx, float qy, float qz, float qw) Multiply this quaternion by the quaternion represented via(qx, qy, qz, qw)
.mul
(float qx, float qy, float qz, float qw, Quaternionf dest) Multiply this quaternion by the quaternion represented via(qx, qy, qz, qw)
and store the result indest
.mul
(float f, Quaternionf dest) Multiply this quaternion by the given scalar and store the result indest
.mul
(Quaternionfc q) Multiply this quaternion byq
.mul
(Quaternionfc q, Quaternionf dest) Multiply this quaternion byq
and store the result indest
.static Quaternionfc
nlerp
(Quaternionfc[] qs, float[] weights, Quaternionf dest) Interpolate between all of the quaternions given inqs
via non-spherical linear interpolation using the specified interpolation factorsweights
, and store the result indest
.nlerp
(Quaternionfc q, float factor) Compute a linear (non-spherical) interpolation ofthis
and the given quaternionq
and store the result inthis
.nlerp
(Quaternionfc q, float factor, Quaternionf dest) Compute a linear (non-spherical) interpolation ofthis
and the given quaternionq
and store the result indest
.static Quaternionfc
nlerpIterative
(Quaternionf[] qs, float[] weights, float dotThreshold, Quaternionf dest) Interpolate between all of the quaternions given inqs
via iterative non-spherical linear interpolation using the specified interpolation factorsweights
, and store the result indest
.nlerpIterative
(Quaternionfc q, float alpha, float dotThreshold) Compute linear (non-spherical) interpolations ofthis
and the given quaternionq
iteratively and store the result inthis
.nlerpIterative
(Quaternionfc q, float alpha, float dotThreshold, Quaternionf dest) Compute linear (non-spherical) interpolations ofthis
and the given quaternionq
iteratively and store the result indest
.Normalize this quaternion.normalize
(Quaternionf dest) Normalize this quaternion and store the result indest
.Obtain the direction of+X
before the rotation transformation represented bythis
normalized quaternion is applied.Obtain the direction of+Y
before the rotation transformation represented bythis
normalized quaternion is applied.Obtain the direction of+Z
before the rotation transformation represented bythis
normalized quaternion is applied.Obtain the direction of+X
before the rotation transformation represented bythis
quaternion is applied.Obtain the direction of+Y
before the rotation transformation represented bythis
quaternion is applied.Obtain the direction of+Z
before the rotation transformation represented bythis
quaternion is applied.premul
(float qx, float qy, float qz, float qw) Pre-multiply this quaternion by the quaternion represented via(qx, qy, qz, qw)
.premul
(float qx, float qy, float qz, float qw, Quaternionf dest) Pre-multiply this quaternion by the quaternion represented via(qx, qy, qz, qw)
and store the result indest
.Pre-multiply this quaternion byq
.premul
(Quaternionfc q, Quaternionf dest) Pre-multiply this quaternion byq
and store the result indest
.void
rotateAxis
(float angle, float axisX, float axisY, float axisZ) Apply a rotation tothis
quaternion rotating the given radians about the specified axis.rotateAxis
(float angle, float axisX, float axisY, float axisZ, Quaternionf dest) Apply a rotation tothis
quaternion rotating the given radians about the specified axis and store the result indest
.rotateAxis
(float angle, Vector3fc axis) Apply a rotation tothis
quaternion rotating the given radians about the specified axis.rotateAxis
(float angle, Vector3fc axis, Quaternionf dest) Apply a rotation tothis
quaternion rotating the given radians about the specified axis and store the result indest
.rotateLocalX
(float angle) Apply a rotation tothis
quaternion rotating the given radians about the local x axis.rotateLocalX
(float angle, Quaternionf dest) Apply a rotation tothis
quaternion rotating the given radians about the local x axis and store the result indest
.rotateLocalY
(float angle) Apply a rotation tothis
quaternion rotating the given radians about the local y axis.rotateLocalY
(float angle, Quaternionf dest) Apply a rotation tothis
quaternion rotating the given radians about the local y axis and store the result indest
.rotateLocalZ
(float angle) Apply a rotation tothis
quaternion rotating the given radians about the local z axis.rotateLocalZ
(float angle, Quaternionf dest) Apply a rotation tothis
quaternion rotating the given radians about the local z axis and store the result indest
.rotateTo
(float fromDirX, float fromDirY, float fromDirZ, float toDirX, float toDirY, float toDirZ) Apply a rotation tothis
that rotates thefromDir
vector to point alongtoDir
.rotateTo
(float fromDirX, float fromDirY, float fromDirZ, float toDirX, float toDirY, float toDirZ, Quaternionf dest) Apply a rotation tothis
that rotates thefromDir
vector to point alongtoDir
and store the result indest
.Apply a rotation tothis
that rotates thefromDir
vector to point alongtoDir
.rotateTo
(Vector3fc fromDir, Vector3fc toDir, Quaternionf dest) Apply a rotation tothis
that rotates thefromDir
vector to point alongtoDir
and store the result indest
.rotateX
(float angle) Apply a rotation tothis
quaternion rotating the given radians about the x axis.rotateX
(float angle, Quaternionf dest) Apply a rotation tothis
quaternion rotating the given radians about the x axis and store the result indest
.rotateXYZ
(float angleX, float angleY, float angleZ) Apply a rotation tothis
quaternion rotating the given radians about the cartesian base unit axes, called the euler angles using rotation sequenceXYZ
.rotateXYZ
(float angleX, float angleY, float angleZ, Quaternionf dest) Apply a rotation tothis
quaternion rotating the given radians about the cartesian base unit axes, called the euler angles using rotation sequenceXYZ
and store the result indest
.rotateY
(float angle) Apply a rotation tothis
quaternion rotating the given radians about the y axis.rotateY
(float angle, Quaternionf dest) Apply a rotation tothis
quaternion rotating the given radians about the y axis and store the result indest
.rotateYXZ
(float angleY, float angleX, float angleZ) Apply a rotation tothis
quaternion rotating the given radians about the cartesian base unit axes, called the euler angles, using the rotation sequenceYXZ
.rotateYXZ
(float angleY, float angleX, float angleZ, Quaternionf dest) Apply a rotation tothis
quaternion rotating the given radians about the cartesian base unit axes, called the euler angles, using the rotation sequenceYXZ
and store the result indest
.rotateZ
(float angle) Apply a rotation tothis
quaternion rotating the given radians about the z axis.rotateZ
(float angle, Quaternionf dest) Apply a rotation tothis
quaternion rotating the given radians about the z axis and store the result indest
.rotateZYX
(float angleZ, float angleY, float angleX) Apply a rotation tothis
quaternion rotating the given radians about the cartesian base unit axes, called the euler angles, using the rotation sequenceZYX
.rotateZYX
(float angleZ, float angleY, float angleX, Quaternionf dest) Apply a rotation tothis
quaternion rotating the given radians about the cartesian base unit axes, called the euler angles, using the rotation sequenceZYX
and store the result indest
.rotationAxis
(float angle, float axisX, float axisY, float axisZ) Set this quaternion to a rotation of the given angle in radians about the supplied axis.rotationAxis
(float angle, Vector3fc axis) Set this quaternion to a rotation of the given angle in radians about the supplied axis.rotationAxis
(AxisAngle4f axisAngle) Set thisQuaternionf
to a rotation of the given angle in radians about the supplied axis, all of which are specified via theAxisAngle4f
.rotationTo
(float fromDirX, float fromDirY, float fromDirZ, float toDirX, float toDirY, float toDirZ) Setthis
quaternion to a rotation that rotates thefromDir
vector to point alongtoDir
.rotationTo
(Vector3fc fromDir, Vector3fc toDir) Setthis
quaternion to a rotation that rotates thefromDir
vector to point alongtoDir
.rotationX
(float angle) Set this quaternion to represent a rotation of the given radians about the x axis.rotationXYZ
(float angleX, float angleY, float angleZ) Set this quaternion from the supplied euler angles (in radians) with rotation order XYZ.rotationY
(float angle) Set this quaternion to represent a rotation of the given radians about the y axis.rotationYXZ
(float angleY, float angleX, float angleZ) Set this quaternion from the supplied euler angles (in radians) with rotation order YXZ.rotationZ
(float angle) Set this quaternion to represent a rotation of the given radians about the z axis.rotationZYX
(float angleZ, float angleY, float angleX) Set this quaternion from the supplied euler angles (in radians) with rotation order ZYX.scale
(float factor) Apply scaling to this quaternion, which results in any vector transformed by this quaternion to change its length by the givenfactor
.scale
(float factor, Quaternionf dest) Apply scaling to this quaternion, which results in any vector transformed by the quaternion to change its length by the givenfactor
, and store the result indest
.scaling
(float factor) Set this quaternion to represent scaling, which results in a transformed vector to change its length by the givenfactor
.set
(float x, float y, float z, float w) Set this quaternion to the given values.set
(AxisAngle4d axisAngle) Set this quaternion to a rotation equivalent to the givenAxisAngle4d
.set
(AxisAngle4f axisAngle) Set this quaternion to a rotation equivalent to the givenAxisAngle4f
.set
(Quaterniondc q) Set this quaternion to be a copy ofq
.set
(Quaternionfc q) Set this quaternion to be a copy ofq
.setAngleAxis
(double angle, double x, double y, double z) Set this quaternion to a rotation equivalent to the supplied axis and angle (in radians).setAngleAxis
(float angle, float x, float y, float z) Set this quaternion to a rotation equivalent to the supplied axis and angle (in radians).Set this quaternion to be a representation of the rotational component of the given matrix.Set this quaternion to be a representation of the rotational component of the given matrix.Set this quaternion to be a representation of the rotational component of the given matrix.Set this quaternion to be a representation of the rotational component of the given matrix.Set this quaternion to be a representation of the rotational component of the given matrix.Set this quaternion to be a representation of the rotational component of the given matrix.Set this quaternion to be a representation of the rotational component of the given matrix.Set this quaternion to be a representation of the rotational component of the given matrix.Set this quaternion to be a representation of the rotational component of the given matrix.Set this quaternion to be a representation of the rotational component of the given matrix.Set this quaternion to be a representation of the rotational component of the given matrix.Set this quaternion to be a representation of the rotational component of the given matrix.static Quaternionfc
slerp
(Quaternionf[] qs, float[] weights, Quaternionf dest) Interpolate between all of the quaternions given inqs
via spherical linear interpolation using the specified interpolation factorsweights
, and store the result indest
.slerp
(Quaternionfc target, float alpha) slerp
(Quaternionfc target, float alpha, Quaternionf dest) toString()
Return a string representation of this quaternion.toString
(NumberFormat formatter) Return a string representation of this quaternion by formatting the components with the givenNumberFormat
.Transform the given vector(x, y, z)
by this quaternion and store the result indest
.Transform the given vector(x, y, z)
by this quaternion and store the result indest
.Transform the given vector(x, y, z)
by this quaternion and store the result indest
.Transform the given vector(x, y, z)
by this quaternion and store the result indest
.Transform the given vector(x, y, z)
by this quaternion and store the result indest
.Transform the given vector by this quaternion.Transform the given vector by this quaternion and store the result indest
.Transform the given vector by this quaternion.Transform the given vector by this quaternion and store the result indest
.Transform the given vector by this quaternion.Transform the given vector by this quaternion and store the result indest
.Transform the given vector by this quaternion.Transform the given vector by this quaternion and store the result indest
.transformInverse
(double x, double y, double z, Vector3d dest) Transform the given vector(x, y, z)
by the inverse of this quaternion and store the result indest
.transformInverse
(double x, double y, double z, Vector4d dest) Transform the given vector(x, y, z)
by the inverse of this quaternion and store the result indest
.transformInverse
(float x, float y, float z, Vector3d dest) Transform the given vector(x, y, z)
by the inverse of this quaternion and store the result indest
.transformInverse
(float x, float y, float z, Vector3f dest) Transform the given vector(x, y, z)
by the inverse of this quaternion and store the result indest
.transformInverse
(float x, float y, float z, Vector4f dest) Transform the given vector(x, y, z)
by the inverse of this quaternion and store the result indest
.transformInverse
(Vector3d vec) Transform the given vector by the inverse of this quaternion.transformInverse
(Vector3dc vec, Vector3d dest) Transform the given vector by the inverse of this quaternion and store the result indest
.transformInverse
(Vector3f vec) Transform the given vector by the inverse of this quaternion.transformInverse
(Vector3fc vec, Vector3f dest) Transform the given vector by the inverse of quaternion and store the result indest
.transformInverse
(Vector4d vec) Transform the given vector by the inverse of this quaternion.transformInverse
(Vector4dc vec, Vector4d dest) Transform the given vector by the inverse of this quaternion and store the result indest
.transformInverse
(Vector4f vec) Transform the given vector by the inverse of this quaternion.transformInverse
(Vector4fc vec, Vector4f dest) Transform the given vector by the inverse of this quaternion and store the result indest
.transformInverseUnit
(double x, double y, double z, Vector3d dest) Transform the given vector(x, y, z)
by the inverse of this unit quaternion and store the result indest
.transformInverseUnit
(double x, double y, double z, Vector4d dest) Transform the given vector(x, y, z)
by the inverse of this unit quaternion and store the result indest
.transformInverseUnit
(float x, float y, float z, Vector3d dest) Transform the given vector(x, y, z)
by the inverse of this unit quaternion and store the result indest
.transformInverseUnit
(float x, float y, float z, Vector3f dest) Transform the given vector(x, y, z)
by the inverse of this unit quaternion and store the result indest
.transformInverseUnit
(float x, float y, float z, Vector4f dest) Transform the given vector(x, y, z)
by the inverse of this unit quaternion and store the result indest
.transformInverseUnit
(Vector3dc vec, Vector3d dest) Transform the given vector by the inverse of this unit quaternion and store the result indest
.Transform the given vector by the inverse of this unit quaternion.transformInverseUnit
(Vector3fc vec, Vector3f dest) Transform the given vector by the inverse of this unit quaternion and store the result indest
.Transform the given vector by the inverse of this unit quaternion.transformInverseUnit
(Vector4dc vec, Vector4d dest) Transform the given vector by the inverse of this unit quaternion and store the result indest
.Transform the given vector by the inverse of this unit quaternion.transformInverseUnit
(Vector4fc vec, Vector4f dest) Transform the given vector by the inverse of this unit quaternion and store the result indest
.transformPositiveX
(Vector3d dest) Transform the vector(1, 0, 0)
by this quaternion.transformPositiveX
(Vector3f dest) Transform the vector(1, 0, 0)
by this quaternion.transformPositiveX
(Vector4d dest) Transform the vector(1, 0, 0)
by this quaternion.transformPositiveX
(Vector4f dest) Transform the vector(1, 0, 0)
by this quaternion.transformPositiveY
(Vector3d dest) Transform the vector(0, 1, 0)
by this quaternion.transformPositiveY
(Vector3f dest) Transform the vector(0, 1, 0)
by this quaternion.transformPositiveY
(Vector4d dest) Transform the vector(0, 1, 0)
by this quaternion.transformPositiveY
(Vector4f dest) Transform the vector(0, 1, 0)
by this quaternion.transformPositiveZ
(Vector3d dest) Transform the vector(0, 0, 1)
by this quaternion.transformPositiveZ
(Vector3f dest) Transform the vector(0, 0, 1)
by this quaternion.transformPositiveZ
(Vector4d dest) Transform the vector(0, 0, 1)
by this quaternion.transformPositiveZ
(Vector4f dest) Transform the vector(0, 0, 1)
by this quaternion.transformUnit
(double x, double y, double z, Vector3d dest) Transform the given vector(x, y, z)
by this unit quaternion and store the result indest
.transformUnit
(double x, double y, double z, Vector4d dest) Transform the given vector(x, y, z)
by this unit quaternion and store the result indest
.transformUnit
(float x, float y, float z, Vector3d dest) Transform the given vector(x, y, z)
by this unit quaternion and store the result indest
.transformUnit
(float x, float y, float z, Vector3f dest) Transform the given vector(x, y, z)
by this unit quaternion and store the result indest
.transformUnit
(float x, float y, float z, Vector4f dest) Transform the given vector(x, y, z)
by this unit quaternion and store the result indest
.transformUnit
(Vector3dc vec, Vector3d dest) Transform the given vector by this unit quaternion and store the result indest
.transformUnit
(Vector3f vec) Transform the given vector by this unit quaternion.transformUnit
(Vector3fc vec, Vector3f dest) Transform the given vector by this unit quaternion and store the result indest
.transformUnit
(Vector4d vec) Transform the given vector by this unit quaternion.transformUnit
(Vector4dc vec, Vector4d dest) Transform the given vector by this unit quaternion and store the result indest
.transformUnit
(Vector4f vec) Transform the given vector by this unit quaternion.transformUnit
(Vector4fc vec, Vector4f dest) Transform the given vector by this unit quaternion and store the result indest
.Transform the vector(1, 0, 0)
by this unit quaternion.Transform the vector(1, 0, 0)
by this unit quaternion.Transform the vector(1, 0, 0)
by this unit quaternion.Transform the vector(1, 0, 0)
by this unit quaternion.Transform the vector(0, 1, 0)
by this unit quaternion.Transform the vector(0, 1, 0)
by this unit quaternion.Transform the vector(0, 1, 0)
by this unit quaternion.Transform the vector(0, 1, 0)
by this unit quaternion.Transform the vector(0, 0, 1)
by this unit quaternion.Transform the vector(0, 0, 1)
by this unit quaternion.Transform the vector(0, 0, 1)
by this unit quaternion.Transform the vector(0, 0, 1)
by this unit quaternion.float
w()
void
float
x()
float
y()
float
z()
-
Field Details
-
x
public float xThe first component of the vector part. -
y
public float yThe second component of the vector part. -
z
public float zThe third component of the vector part. -
w
public float wThe real/scalar part of the quaternion.
-
-
Constructor Details
-
Quaternionf
public Quaternionf()Create a newQuaternionf
and initialize it with(x=0, y=0, z=0, w=1)
, where(x, y, z)
is the vector part of the quaternion andw
is the real/scalar part. -
Quaternionf
public Quaternionf(double x, double y, double z, double w) Create a newQuaternionf
and initialize its components to the given values.- Parameters:
x
- the first component of the imaginary party
- the second component of the imaginary partz
- the third component of the imaginary partw
- the real part
-
Quaternionf
public Quaternionf(float x, float y, float z, float w) Create a newQuaternionf
and initialize its components to the given values.- Parameters:
x
- the first component of the imaginary party
- the second component of the imaginary partz
- the third component of the imaginary partw
- the real part
-
Quaternionf
Create a newQuaternionf
and initialize its components to the same values as the givenQuaternionfc
.- Parameters:
source
- theQuaternionfc
to take the component values from
-
Quaternionf
Create a newQuaternionf
and initialize its components to the same values as the givenQuaterniondc
.- Parameters:
source
- theQuaterniondc
to take the component values from
-
Quaternionf
Create a newQuaternionf
which represents the rotation of the givenAxisAngle4f
.- Parameters:
axisAngle
- theAxisAngle4f
-
Quaternionf
Create a newQuaterniond
which represents the rotation of the givenAxisAngle4d
.- Parameters:
axisAngle
- theAxisAngle4d
-
-
Method Details
-
x
public float x()- Specified by:
x
in interfaceQuaternionfc
- Returns:
- the first component of the vector part
-
y
public float y()- Specified by:
y
in interfaceQuaternionfc
- Returns:
- the second component of the vector part
-
z
public float z()- Specified by:
z
in interfaceQuaternionfc
- Returns:
- the third component of the vector part
-
w
public float w()- Specified by:
w
in interfaceQuaternionfc
- Returns:
- the real/scalar part of the quaternion
-
normalize
Normalize this quaternion.- Returns:
- this
-
normalize
Description copied from interface:Quaternionfc
Normalize this quaternion and store the result indest
.- Specified by:
normalize
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
add
Add the quaternion(x, y, z, w)
to this quaternion.- Parameters:
x
- the x component of the vector party
- the y component of the vector partz
- the z component of the vector partw
- the real/scalar component- Returns:
- this
-
add
Description copied from interface:Quaternionfc
Add the quaternion(x, y, z, w)
to this quaternion and store the result indest
.- Specified by:
add
in interfaceQuaternionfc
- Parameters:
x
- the x component of the vector party
- the y component of the vector partz
- the z component of the vector partw
- the real/scalar componentdest
- will hold the result- Returns:
- dest
-
add
Addq2
to this quaternion.- Parameters:
q2
- the quaternion to add to this- Returns:
- this
-
add
Description copied from interface:Quaternionfc
Addq2
to this quaternion and store the result indest
.- Specified by:
add
in interfaceQuaternionfc
- Parameters:
q2
- the quaternion to add to thisdest
- will hold the result- Returns:
- dest
-
dot
Return the dot of this quaternion andotherQuat
.- Parameters:
otherQuat
- the other quaternion- Returns:
- the dot product
-
angle
public float angle()Description copied from interface:Quaternionfc
Return the angle in radians represented by this normalized quaternion rotation.This quaternion must be
normalized
.- Specified by:
angle
in interfaceQuaternionfc
- Returns:
- the angle in radians
-
get
Description copied from interface:Quaternionfc
Set the given destination matrix to the rotation represented bythis
.- Specified by:
get
in interfaceQuaternionfc
- Parameters:
dest
- the matrix to write the rotation into- Returns:
- the passed in destination
- See Also:
-
get
Description copied from interface:Quaternionfc
Set the given destination matrix to the rotation represented bythis
.- Specified by:
get
in interfaceQuaternionfc
- Parameters:
dest
- the matrix to write the rotation into- Returns:
- the passed in destination
- See Also:
-
get
Description copied from interface:Quaternionfc
Set the given destination matrix to the rotation represented bythis
.- Specified by:
get
in interfaceQuaternionfc
- Parameters:
dest
- the matrix to write the rotation into- Returns:
- the passed in destination
- See Also:
-
get
Description copied from interface:Quaternionfc
Set the given destination matrix to the rotation represented bythis
.- Specified by:
get
in interfaceQuaternionfc
- Parameters:
dest
- the matrix to write the rotation into- Returns:
- the passed in destination
- See Also:
-
get
Description copied from interface:Quaternionfc
Set the given destination matrix to the rotation represented bythis
.- Specified by:
get
in interfaceQuaternionfc
- Parameters:
dest
- the matrix to write the rotation into- Returns:
- the passed in destination
- See Also:
-
get
Description copied from interface:Quaternionfc
Set the given destination matrix to the rotation represented bythis
.- Specified by:
get
in interfaceQuaternionfc
- Parameters:
dest
- the matrix to write the rotation into- Returns:
- the passed in destination
- See Also:
-
get
Description copied from interface:Quaternionfc
Set the givenAxisAngle4f
to represent the rotation ofthis
quaternion.- Specified by:
get
in interfaceQuaternionfc
- Parameters:
dest
- theAxisAngle4f
to set- Returns:
- the passed in destination
-
get
Description copied from interface:Quaternionfc
Set the givenAxisAngle4d
to represent the rotation ofthis
quaternion.- Specified by:
get
in interfaceQuaternionfc
- Parameters:
dest
- theAxisAngle4d
to set- Returns:
- the passed in destination
-
get
Description copied from interface:Quaternionfc
Set the givenQuaterniond
to the values ofthis
.- Specified by:
get
in interfaceQuaternionfc
- Parameters:
dest
- theQuaterniond
to set- Returns:
- the passed in destination
- See Also:
-
get
Set the givenQuaternionf
to the values ofthis
.- Specified by:
get
in interfaceQuaternionfc
- Parameters:
dest
- theQuaternionf
to set- Returns:
- the passed in destination
- See Also:
-
getAsMatrix3f
Description copied from interface:Quaternionfc
Store the 3x3 float matrix representation ofthis
quaternion in column-major order into the givenByteBuffer
.This is equivalent to calling:
this.get(new Matrix3f()).get(dest)
- Specified by:
getAsMatrix3f
in interfaceQuaternionfc
- Parameters:
dest
- the destination buffer- Returns:
- dest
-
getAsMatrix3f
Description copied from interface:Quaternionfc
Store the 3x3 float matrix representation ofthis
quaternion in column-major order into the givenFloatBuffer
.This is equivalent to calling:
this.get(new Matrix3f()).get(dest)
- Specified by:
getAsMatrix3f
in interfaceQuaternionfc
- Parameters:
dest
- the destination buffer- Returns:
- dest
-
getAsMatrix4f
Description copied from interface:Quaternionfc
Store the 4x4 float matrix representation ofthis
quaternion in column-major order into the givenByteBuffer
.This is equivalent to calling:
this.get(new Matrix4f()).get(dest)
- Specified by:
getAsMatrix4f
in interfaceQuaternionfc
- Parameters:
dest
- the destination buffer- Returns:
- dest
-
getAsMatrix4f
Description copied from interface:Quaternionfc
Store the 4x4 float matrix representation ofthis
quaternion in column-major order into the givenFloatBuffer
.This is equivalent to calling:
this.get(new Matrix4f()).get(dest)
- Specified by:
getAsMatrix4f
in interfaceQuaternionfc
- Parameters:
dest
- the destination buffer- Returns:
- dest
-
getAsMatrix4x3f
Description copied from interface:Quaternionfc
Store the 4x3 float matrix representation ofthis
quaternion in column-major order into the givenByteBuffer
.This is equivalent to calling:
this.get(new Matrix4x3f()).get(dest)
- Specified by:
getAsMatrix4x3f
in interfaceQuaternionfc
- Parameters:
dest
- the destination buffer- Returns:
- dest
-
getAsMatrix4x3f
Description copied from interface:Quaternionfc
Store the 4x3 float matrix representation ofthis
quaternion in column-major order into the givenFloatBuffer
.This is equivalent to calling:
this.get(new Matrix4x3f()).get(dest)
- Specified by:
getAsMatrix4x3f
in interfaceQuaternionfc
- Parameters:
dest
- the destination buffer- Returns:
- dest
-
set
Set this quaternion to the given values.- Parameters:
x
- the new value of xy
- the new value of yz
- the new value of zw
- the new value of w- Returns:
- this
-
set
Set this quaternion to be a copy ofq
.- Parameters:
q
- theQuaternionfc
to copy- Returns:
- this
-
set
Set this quaternion to be a copy ofq
.- Parameters:
q
- theQuaterniondc
to copy- Returns:
- this
-
set
Set this quaternion to a rotation equivalent to the givenAxisAngle4f
.- Parameters:
axisAngle
- theAxisAngle4f
- Returns:
- this
-
set
Set this quaternion to a rotation equivalent to the givenAxisAngle4d
.- Parameters:
axisAngle
- theAxisAngle4d
- Returns:
- this
-
setAngleAxis
Set this quaternion to a rotation equivalent to the supplied axis and angle (in radians).This method assumes that the given rotation axis
(x, y, z)
is already normalized- Parameters:
angle
- the angle in radiansx
- the x-component of the normalized rotation axisy
- the y-component of the normalized rotation axisz
- the z-component of the normalized rotation axis- Returns:
- this
-
setAngleAxis
Set this quaternion to a rotation equivalent to the supplied axis and angle (in radians).This method assumes that the given rotation axis
(x, y, z)
is already normalized- Parameters:
angle
- the angle in radiansx
- the x-component of the normalized rotation axisy
- the y-component of the normalized rotation axisz
- the z-component of the normalized rotation axis- Returns:
- this
-
rotationAxis
Set thisQuaternionf
to a rotation of the given angle in radians about the supplied axis, all of which are specified via theAxisAngle4f
.- Parameters:
axisAngle
- theAxisAngle4f
giving the rotation angle in radians and the axis to rotate about- Returns:
- this
- See Also:
-
rotationAxis
Set this quaternion to a rotation of the given angle in radians about the supplied axis.- Parameters:
angle
- the rotation angle in radiansaxisX
- the x-coordinate of the rotation axisaxisY
- the y-coordinate of the rotation axisaxisZ
- the z-coordinate of the rotation axis- Returns:
- this
-
rotationAxis
Set this quaternion to a rotation of the given angle in radians about the supplied axis.- Parameters:
angle
- the rotation angle in radiansaxis
- the axis to rotate about- Returns:
- this
- See Also:
-
rotationX
Set this quaternion to represent a rotation of the given radians about the x axis.- Parameters:
angle
- the angle in radians to rotate about the x axis- Returns:
- this
-
rotationY
Set this quaternion to represent a rotation of the given radians about the y axis.- Parameters:
angle
- the angle in radians to rotate about the y axis- Returns:
- this
-
rotationZ
Set this quaternion to represent a rotation of the given radians about the z axis.- Parameters:
angle
- the angle in radians to rotate about the z axis- Returns:
- this
-
setFromUnnormalized
Set this quaternion to be a representation of the rotational component of the given matrix.This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.
- Parameters:
mat
- the matrix whose rotational component is used to set this quaternion- Returns:
- this
-
setFromUnnormalized
Set this quaternion to be a representation of the rotational component of the given matrix.This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.
- Parameters:
mat
- the matrix whose rotational component is used to set this quaternion- Returns:
- this
-
setFromUnnormalized
Set this quaternion to be a representation of the rotational component of the given matrix.This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.
- Parameters:
mat
- the matrix whose rotational component is used to set this quaternion- Returns:
- this
-
setFromNormalized
Set this quaternion to be a representation of the rotational component of the given matrix.This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.
- Parameters:
mat
- the matrix whose rotational component is used to set this quaternion- Returns:
- this
-
setFromNormalized
Set this quaternion to be a representation of the rotational component of the given matrix.This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.
- Parameters:
mat
- the matrix whose rotational component is used to set this quaternion- Returns:
- this
-
setFromNormalized
Set this quaternion to be a representation of the rotational component of the given matrix.This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.
- Parameters:
mat
- the matrix whose rotational component is used to set this quaternion- Returns:
- this
-
setFromUnnormalized
Set this quaternion to be a representation of the rotational component of the given matrix.This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.
- Parameters:
mat
- the matrix whose rotational component is used to set this quaternion- Returns:
- this
-
setFromNormalized
Set this quaternion to be a representation of the rotational component of the given matrix.This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.
- Parameters:
mat
- the matrix whose rotational component is used to set this quaternion- Returns:
- this
-
setFromUnnormalized
Set this quaternion to be a representation of the rotational component of the given matrix.This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.
- Parameters:
mat
- the matrix whose rotational component is used to set this quaternion- Returns:
- this
-
setFromNormalized
Set this quaternion to be a representation of the rotational component of the given matrix.This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.
- Parameters:
mat
- the matrix whose rotational component is used to set this quaternion- Returns:
- this
-
setFromUnnormalized
Set this quaternion to be a representation of the rotational component of the given matrix.This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.
- Parameters:
mat
- the matrix whose rotational component is used to set this quaternion- Returns:
- this
-
setFromNormalized
Set this quaternion to be a representation of the rotational component of the given matrix.- Parameters:
mat
- the matrix whose rotational component is used to set this quaternion- Returns:
- this
-
fromAxisAngleRad
Set this quaternion to be a representation of the supplied axis and angle (in radians).- Parameters:
axis
- the rotation axisangle
- the angle in radians- Returns:
- this
-
fromAxisAngleRad
Set this quaternion to be a representation of the supplied axis and angle (in radians).- Parameters:
axisX
- the x component of the rotation axisaxisY
- the y component of the rotation axisaxisZ
- the z component of the rotation axisangle
- the angle in radians- Returns:
- this
-
fromAxisAngleDeg
Set this quaternion to be a representation of the supplied axis and angle (in degrees).- Parameters:
axis
- the rotation axisangle
- the angle in degrees- Returns:
- this
-
fromAxisAngleDeg
Set this quaternion to be a representation of the supplied axis and angle (in degrees).- Parameters:
axisX
- the x component of the rotation axisaxisY
- the y component of the rotation axisaxisZ
- the z component of the rotation axisangle
- the angle in radians- Returns:
- this
-
mul
Multiply this quaternion byq
.If
T
isthis
andQ
is the given quaternion, then the resulting quaternionR
is:R = T * Q
So, this method uses post-multiplication like the matrix classes, resulting in a vector to be transformed by
Q
first, and then byT
.- Parameters:
q
- the quaternion to multiplythis
by- Returns:
- this
-
mul
Description copied from interface:Quaternionfc
Multiply this quaternion byq
and store the result indest
.If
T
isthis
andQ
is the given quaternion, then the resulting quaternionR
is:R = T * Q
So, this method uses post-multiplication like the matrix classes, resulting in a vector to be transformed by
Q
first, and then byT
.- Specified by:
mul
in interfaceQuaternionfc
- Parameters:
q
- the quaternion to multiplythis
bydest
- will hold the result- Returns:
- dest
-
mul
Multiply this quaternion by the quaternion represented via(qx, qy, qz, qw)
.If
T
isthis
andQ
is the given quaternion, then the resulting quaternionR
is:R = T * Q
So, this method uses post-multiplication like the matrix classes, resulting in a vector to be transformed by
Q
first, and then byT
.- Parameters:
qx
- the x component of the quaternion to multiplythis
byqy
- the y component of the quaternion to multiplythis
byqz
- the z component of the quaternion to multiplythis
byqw
- the w component of the quaternion to multiplythis
by- Returns:
- this
-
mul
Description copied from interface:Quaternionfc
Multiply this quaternion by the quaternion represented via(qx, qy, qz, qw)
and store the result indest
.If
T
isthis
andQ
is the given quaternion, then the resulting quaternionR
is:R = T * Q
So, this method uses post-multiplication like the matrix classes, resulting in a vector to be transformed by
Q
first, and then byT
.- Specified by:
mul
in interfaceQuaternionfc
- Parameters:
qx
- the x component of the quaternion to multiplythis
byqy
- the y component of the quaternion to multiplythis
byqz
- the z component of the quaternion to multiplythis
byqw
- the w component of the quaternion to multiplythis
bydest
- will hold the result- Returns:
- dest
-
mul
Multiply this quaternion by the given scalar.This method multiplies all of the four components by the specified scalar.
- Parameters:
f
- the factor to multiply all components by- Returns:
- this
-
mul
Description copied from interface:Quaternionfc
Multiply this quaternion by the given scalar and store the result indest
.This method multiplies all of the four components by the specified scalar.
- Specified by:
mul
in interfaceQuaternionfc
- Parameters:
f
- the factor to multiply all components bydest
- will hold the result- Returns:
- dest
-
premul
Pre-multiply this quaternion byq
.If
T
isthis
andQ
is the given quaternion, then the resulting quaternionR
is:R = Q * T
So, this method uses pre-multiplication, resulting in a vector to be transformed by
T
first, and then byQ
.- Parameters:
q
- the quaternion to pre-multiplythis
by- Returns:
- this
-
premul
Description copied from interface:Quaternionfc
Pre-multiply this quaternion byq
and store the result indest
.If
T
isthis
andQ
is the given quaternion, then the resulting quaternionR
is:R = Q * T
So, this method uses pre-multiplication, resulting in a vector to be transformed by
T
first, and then byQ
.- Specified by:
premul
in interfaceQuaternionfc
- Parameters:
q
- the quaternion to pre-multiplythis
bydest
- will hold the result- Returns:
- dest
-
premul
Pre-multiply this quaternion by the quaternion represented via(qx, qy, qz, qw)
.If
T
isthis
andQ
is the given quaternion, then the resulting quaternionR
is:R = Q * T
So, this method uses pre-multiplication, resulting in a vector to be transformed by
T
first, and then byQ
.- Parameters:
qx
- the x component of the quaternion to multiplythis
byqy
- the y component of the quaternion to multiplythis
byqz
- the z component of the quaternion to multiplythis
byqw
- the w component of the quaternion to multiplythis
by- Returns:
- this
-
premul
Description copied from interface:Quaternionfc
Pre-multiply this quaternion by the quaternion represented via(qx, qy, qz, qw)
and store the result indest
.If
T
isthis
andQ
is the given quaternion, then the resulting quaternionR
is:R = Q * T
So, this method uses pre-multiplication, resulting in a vector to be transformed by
T
first, and then byQ
.- Specified by:
premul
in interfaceQuaternionfc
- Parameters:
qx
- the x component of the quaternion to multiplythis
byqy
- the y component of the quaternion to multiplythis
byqz
- the z component of the quaternion to multiplythis
byqw
- the w component of the quaternion to multiplythis
bydest
- will hold the result- Returns:
- dest
-
transform
Description copied from interface:Quaternionfc
Transform the given vector by this quaternion.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this quaternion.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transformPositiveX
Description copied from interface:Quaternionfc
Transform the vector(1, 0, 0)
by this quaternion.- Specified by:
transformPositiveX
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformPositiveX
Description copied from interface:Quaternionfc
Transform the vector(1, 0, 0)
by this quaternion.Only the first three components of the given 4D vector are modified.
- Specified by:
transformPositiveX
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformUnitPositiveX
Description copied from interface:Quaternionfc
Transform the vector(1, 0, 0)
by this unit quaternion.This method is only applicable when
this
is a unit quaternion.Reference: https://de.mathworks.com/
- Specified by:
transformUnitPositiveX
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformUnitPositiveX
Description copied from interface:Quaternionfc
Transform the vector(1, 0, 0)
by this unit quaternion.Only the first three components of the given 4D vector are modified.
This method is only applicable when
this
is a unit quaternion.Reference: https://de.mathworks.com/
- Specified by:
transformUnitPositiveX
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformPositiveY
Description copied from interface:Quaternionfc
Transform the vector(0, 1, 0)
by this quaternion.- Specified by:
transformPositiveY
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformPositiveY
Description copied from interface:Quaternionfc
Transform the vector(0, 1, 0)
by this quaternion.Only the first three components of the given 4D vector are modified.
- Specified by:
transformPositiveY
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformUnitPositiveY
Description copied from interface:Quaternionfc
Transform the vector(0, 1, 0)
by this unit quaternion.Only the first three components of the given 4D vector are modified.
This method is only applicable when
this
is a unit quaternion.Reference: https://de.mathworks.com/
- Specified by:
transformUnitPositiveY
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformUnitPositiveY
Description copied from interface:Quaternionfc
Transform the vector(0, 1, 0)
by this unit quaternion.This method is only applicable when
this
is a unit quaternion.Reference: https://de.mathworks.com/
- Specified by:
transformUnitPositiveY
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformPositiveZ
Description copied from interface:Quaternionfc
Transform the vector(0, 0, 1)
by this quaternion.- Specified by:
transformPositiveZ
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformPositiveZ
Description copied from interface:Quaternionfc
Transform the vector(0, 0, 1)
by this quaternion.Only the first three components of the given 4D vector are modified.
- Specified by:
transformPositiveZ
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformUnitPositiveZ
Description copied from interface:Quaternionfc
Transform the vector(0, 0, 1)
by this unit quaternion.Only the first three components of the given 4D vector are modified.
This method is only applicable when
this
is a unit quaternion.Reference: https://de.mathworks.com/
- Specified by:
transformUnitPositiveZ
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformUnitPositiveZ
Description copied from interface:Quaternionfc
Transform the vector(0, 0, 1)
by this unit quaternion.This method is only applicable when
this
is a unit quaternion.Reference: https://de.mathworks.com/
- Specified by:
transformUnitPositiveZ
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transform
Description copied from interface:Quaternionfc
Transform the given vector by this quaternion.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and modified.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this quaternion.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and modified.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transform
Description copied from interface:Quaternionfc
Transform the given vector by this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transform
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by the inverse of this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformUnit
Description copied from interface:Quaternionfc
Transform the given vector by this unit quaternion.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transformInverseUnit
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this unit quaternion.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformInverseUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transformUnit
Description copied from interface:Quaternionfc
Transform the given vector by this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverseUnit
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformInverseUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transformUnit
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformUnit
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverseUnit
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by the inverse of this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformInverseUnit
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transform
Description copied from interface:Quaternionfc
Transform the given vector by this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and set on the destination.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and set on the destination.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transform
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by the inverse of this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transform
Description copied from interface:Quaternionfc
Transform the given vector by this quaternion.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this quaternion.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transformUnit
Description copied from interface:Quaternionfc
Transform the given vector by this unit quaternion.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and set on the destination.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transformInverseUnit
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this unit quaternion.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and set on the destination.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformInverseUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transformUnit
Description copied from interface:Quaternionfc
Transform the given vector by this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and set on the destination.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverseUnit
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and set on the destination.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformInverseUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transformUnit
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformUnit
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverseUnit
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by the inverse of this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformInverseUnit
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformPositiveX
Description copied from interface:Quaternionfc
Transform the vector(1, 0, 0)
by this quaternion.- Specified by:
transformPositiveX
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformPositiveX
Description copied from interface:Quaternionfc
Transform the vector(1, 0, 0)
by this quaternion.Only the first three components of the given 4D vector are modified.
- Specified by:
transformPositiveX
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformUnitPositiveX
Description copied from interface:Quaternionfc
Transform the vector(1, 0, 0)
by this unit quaternion.This method is only applicable when
this
is a unit quaternion.Reference: https://de.mathworks.com/
- Specified by:
transformUnitPositiveX
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformUnitPositiveX
Description copied from interface:Quaternionfc
Transform the vector(1, 0, 0)
by this unit quaternion.Only the first three components of the given 4D vector are modified.
This method is only applicable when
this
is a unit quaternion.Reference: https://de.mathworks.com/
- Specified by:
transformUnitPositiveX
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformPositiveY
Description copied from interface:Quaternionfc
Transform the vector(0, 1, 0)
by this quaternion.- Specified by:
transformPositiveY
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformPositiveY
Description copied from interface:Quaternionfc
Transform the vector(0, 1, 0)
by this quaternion.Only the first three components of the given 4D vector are modified.
- Specified by:
transformPositiveY
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformUnitPositiveY
Description copied from interface:Quaternionfc
Transform the vector(0, 1, 0)
by this unit quaternion.Only the first three components of the given 4D vector are modified.
This method is only applicable when
this
is a unit quaternion.Reference: https://de.mathworks.com/
- Specified by:
transformUnitPositiveY
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformUnitPositiveY
Description copied from interface:Quaternionfc
Transform the vector(0, 1, 0)
by this unit quaternion.This method is only applicable when
this
is a unit quaternion.Reference: https://de.mathworks.com/
- Specified by:
transformUnitPositiveY
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformPositiveZ
Description copied from interface:Quaternionfc
Transform the vector(0, 0, 1)
by this quaternion.- Specified by:
transformPositiveZ
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformPositiveZ
Description copied from interface:Quaternionfc
Transform the vector(0, 0, 1)
by this quaternion.Only the first three components of the given 4D vector are modified.
- Specified by:
transformPositiveZ
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformUnitPositiveZ
Description copied from interface:Quaternionfc
Transform the vector(0, 0, 1)
by this unit quaternion.Only the first three components of the given 4D vector are modified.
This method is only applicable when
this
is a unit quaternion.Reference: https://de.mathworks.com/
- Specified by:
transformUnitPositiveZ
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transformUnitPositiveZ
Description copied from interface:Quaternionfc
Transform the vector(0, 0, 1)
by this unit quaternion.This method is only applicable when
this
is a unit quaternion.Reference: https://de.mathworks.com/
- Specified by:
transformUnitPositiveZ
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
transform
Description copied from interface:Quaternionfc
Transform the given vector by this quaternion.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and modified.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this quaternion.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and modified.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transform
Description copied from interface:Quaternionfc
Transform the given vector by this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transform
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by the inverse of this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transform
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by the inverse of this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transform
Description copied from interface:Quaternionfc
Transform the given vector by this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and set on the destination.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and set on the destination.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transform
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transform
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverse
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by the inverse of this quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
- Specified by:
transformInverse
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformUnit
Description copied from interface:Quaternionfc
Transform the given vector by this unit quaternion.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and modified.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transformInverseUnit
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this unit quaternion.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and modified.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformInverseUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transform- Returns:
- vec
-
transformUnit
Description copied from interface:Quaternionfc
Transform the given vector by this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverseUnit
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformInverseUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transformUnit
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformUnit
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverseUnit
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by the inverse of this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformInverseUnit
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformUnit
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformUnit
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverseUnit
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by the inverse of this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformInverseUnit
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformUnit
Description copied from interface:Quaternionfc
Transform the given vector by this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and set on the destination.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverseUnit
Description copied from interface:Quaternionfc
Transform the given vector by the inverse of this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
Only the first three components of the given 4D vector are being used and set on the destination.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformInverseUnit
in interfaceQuaternionfc
- Parameters:
vec
- the vector to transformdest
- will hold the result- Returns:
- dest
-
transformUnit
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformUnit
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
transformInverseUnit
Description copied from interface:Quaternionfc
Transform the given vector(x, y, z)
by the inverse of this unit quaternion and store the result indest
.This will apply the rotation described by this quaternion to the given vector.
This method is only applicable when
this
is a unit quaternion.- Specified by:
transformInverseUnit
in interfaceQuaternionfc
- Parameters:
x
- the x coordinate of the vector to transformy
- the y coordinate of the vector to transformz
- the z coordinate of the vector to transformdest
- will hold the result- Returns:
- dest
-
invert
Description copied from interface:Quaternionfc
Invert this quaternion and store thenormalized
result indest
.If this quaternion is already normalized, then
Quaternionfc.conjugate(Quaternionf)
should be used instead.- Specified by:
invert
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
- See Also:
-
invert
Invert this quaternion andnormalize
it.If this quaternion is already normalized, then
conjugate()
should be used instead.- Returns:
- this
- See Also:
-
div
Description copied from interface:Quaternionfc
Dividethis
quaternion byb
and store the result indest
.The division expressed using the inverse is performed in the following way:
dest = this * b^-1
, whereb^-1
is the inverse ofb
.- Specified by:
div
in interfaceQuaternionfc
- Parameters:
b
- theQuaternionfc
to divide this bydest
- will hold the result- Returns:
- dest
-
div
Dividethis
quaternion byb
.The division expressed using the inverse is performed in the following way:
this = this * b^-1
, whereb^-1
is the inverse ofb
.- Parameters:
b
- theQuaternionf
to divide this by- Returns:
- this
-
conjugate
Conjugate this quaternion.- Returns:
- this
-
conjugate
Description copied from interface:Quaternionfc
Conjugate this quaternion and store the result indest
.- Specified by:
conjugate
in interfaceQuaternionfc
- Parameters:
dest
- will hold the result- Returns:
- dest
-
identity
Set this quaternion to the identity.- Returns:
- this
-
rotateXYZ
Apply a rotation tothis
quaternion rotating the given radians about the cartesian base unit axes, called the euler angles using rotation sequenceXYZ
.This method is equivalent to calling:
rotateX(angleX).rotateY(angleY).rotateZ(angleZ)
If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Parameters:
angleX
- the angle in radians to rotate about the x axisangleY
- the angle in radians to rotate about the y axisangleZ
- the angle in radians to rotate about the z axis- Returns:
- this
-
rotateXYZ
Description copied from interface:Quaternionfc
Apply a rotation tothis
quaternion rotating the given radians about the cartesian base unit axes, called the euler angles using rotation sequenceXYZ
and store the result indest
.This method is equivalent to calling:
rotateX(angleX, dest).rotateY(angleY).rotateZ(angleZ)
If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Specified by:
rotateXYZ
in interfaceQuaternionfc
- Parameters:
angleX
- the angle in radians to rotate about the x axisangleY
- the angle in radians to rotate about the y axisangleZ
- the angle in radians to rotate about the z axisdest
- will hold the result- Returns:
- dest
-
rotateZYX
Apply a rotation tothis
quaternion rotating the given radians about the cartesian base unit axes, called the euler angles, using the rotation sequenceZYX
.This method is equivalent to calling:
rotateZ(angleZ).rotateY(angleY).rotateX(angleX)
If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Parameters:
angleZ
- the angle in radians to rotate about the z axisangleY
- the angle in radians to rotate about the y axisangleX
- the angle in radians to rotate about the x axis- Returns:
- this
-
rotateZYX
Description copied from interface:Quaternionfc
Apply a rotation tothis
quaternion rotating the given radians about the cartesian base unit axes, called the euler angles, using the rotation sequenceZYX
and store the result indest
.This method is equivalent to calling:
rotateZ(angleZ, dest).rotateY(angleY).rotateX(angleX)
If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Specified by:
rotateZYX
in interfaceQuaternionfc
- Parameters:
angleZ
- the angle in radians to rotate about the z axisangleY
- the angle in radians to rotate about the y axisangleX
- the angle in radians to rotate about the x axisdest
- will hold the result- Returns:
- dest
-
rotateYXZ
Apply a rotation tothis
quaternion rotating the given radians about the cartesian base unit axes, called the euler angles, using the rotation sequenceYXZ
.This method is equivalent to calling:
rotateY(angleY).rotateX(angleX).rotateZ(angleZ)
If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Parameters:
angleY
- the angle in radians to rotate about the y axisangleX
- the angle in radians to rotate about the x axisangleZ
- the angle in radians to rotate about the z axis- Returns:
- this
-
rotateYXZ
Description copied from interface:Quaternionfc
Apply a rotation tothis
quaternion rotating the given radians about the cartesian base unit axes, called the euler angles, using the rotation sequenceYXZ
and store the result indest
.This method is equivalent to calling:
rotateY(angleY, dest).rotateX(angleX).rotateZ(angleZ)
If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Specified by:
rotateYXZ
in interfaceQuaternionfc
- Parameters:
angleY
- the angle in radians to rotate about the y axisangleX
- the angle in radians to rotate about the x axisangleZ
- the angle in radians to rotate about the z axisdest
- will hold the result- Returns:
- dest
-
getEulerAnglesXYZ
Description copied from interface:Quaternionfc
Get the euler angles in radians in rotation sequenceXYZ
of this quaternion and store them in the provided parametereulerAngles
.The Euler angles are always returned as the angle around X in the
Vector3f.x
field, the angle around Y in theVector3f.y
field and the angle around Z in theVector3f.z
field of the suppliedVector3f
instance.- Specified by:
getEulerAnglesXYZ
in interfaceQuaternionfc
- Parameters:
eulerAngles
- will hold the euler angles in radians- Returns:
- the passed in vector
-
getEulerAnglesZYX
Description copied from interface:Quaternionfc
Get the euler angles in radians in rotation sequenceZYX
of this quaternion and store them in the provided parametereulerAngles
.The Euler angles are always returned as the angle around X in the
Vector3f.x
field, the angle around Y in theVector3f.y
field and the angle around Z in theVector3f.z
field of the suppliedVector3f
instance.- Specified by:
getEulerAnglesZYX
in interfaceQuaternionfc
- Parameters:
eulerAngles
- will hold the euler angles in radians- Returns:
- the passed in vector
-
getEulerAnglesZXY
Description copied from interface:Quaternionfc
Get the euler angles in radians in rotation sequenceZXY
of this quaternion and store them in the provided parametereulerAngles
.The Euler angles are always returned as the angle around X in the
Vector3f.x
field, the angle around Y in theVector3f.y
field and the angle around Z in theVector3f.z
field of the suppliedVector3f
instance.- Specified by:
getEulerAnglesZXY
in interfaceQuaternionfc
- Parameters:
eulerAngles
- will hold the euler angles in radians- Returns:
- the passed in vector
-
getEulerAnglesYXZ
Description copied from interface:Quaternionfc
Get the euler angles in radians in rotation sequenceYXZ
of this quaternion and store them in the provided parametereulerAngles
.The Euler angles are always returned as the angle around X in the
Vector3f.x
field, the angle around Y in theVector3f.y
field and the angle around Z in theVector3f.z
field of the suppliedVector3f
instance.- Specified by:
getEulerAnglesYXZ
in interfaceQuaternionfc
- Parameters:
eulerAngles
- will hold the euler angles in radians- Returns:
- the passed in vector
-
lengthSquared
public float lengthSquared()Description copied from interface:Quaternionfc
Return the square of the length of this quaternion.- Specified by:
lengthSquared
in interfaceQuaternionfc
- Returns:
- the length
-
rotationXYZ
Set this quaternion from the supplied euler angles (in radians) with rotation order XYZ.This method is equivalent to calling:
rotationX(angleX).rotateY(angleY).rotateZ(angleZ)
Reference: this stackexchange answer
- Parameters:
angleX
- the angle in radians to rotate about xangleY
- the angle in radians to rotate about yangleZ
- the angle in radians to rotate about z- Returns:
- this
-
rotationZYX
Set this quaternion from the supplied euler angles (in radians) with rotation order ZYX.This method is equivalent to calling:
rotationZ(angleZ).rotateY(angleY).rotateX(angleX)
Reference: this stackexchange answer
- Parameters:
angleX
- the angle in radians to rotate about xangleY
- the angle in radians to rotate about yangleZ
- the angle in radians to rotate about z- Returns:
- this
-
rotationYXZ
Set this quaternion from the supplied euler angles (in radians) with rotation order YXZ.This method is equivalent to calling:
rotationY(angleY).rotateX(angleX).rotateZ(angleZ)
Reference: https://en.wikipedia.org
- Parameters:
angleY
- the angle in radians to rotate about yangleX
- the angle in radians to rotate about xangleZ
- the angle in radians to rotate about z- Returns:
- this
-
slerp
Interpolate betweenthis
unit
quaternion and the specifiedtarget
unit
quaternion using spherical linear interpolation using the specified interpolation factoralpha
.This method resorts to non-spherical linear interpolation when the absolute dot product of
this
andtarget
is below1E-6f
.- Parameters:
target
- the target of the interpolation, which should be reached withalpha = 1.0
alpha
- the interpolation factor, within[0..1]
- Returns:
- this
-
slerp
Description copied from interface:Quaternionfc
Interpolate betweenthis
unit
quaternion and the specifiedtarget
unit
quaternion using spherical linear interpolation using the specified interpolation factoralpha
, and store the result indest
.This method resorts to non-spherical linear interpolation when the absolute dot product of
this
andtarget
is below1E-6f
.Reference: http://fabiensanglard.net
- Specified by:
slerp
in interfaceQuaternionfc
- Parameters:
target
- the target of the interpolation, which should be reached withalpha = 1.0
alpha
- the interpolation factor, within[0..1]
dest
- will hold the result- Returns:
- dest
-
slerp
Interpolate between all of the quaternions given inqs
via spherical linear interpolation using the specified interpolation factorsweights
, and store the result indest
.This method will interpolate between each two successive quaternions via
slerp(Quaternionfc, float)
using their relative interpolation weights.This method resorts to non-spherical linear interpolation when the absolute dot product of any two interpolated quaternions is below
1E-6f
.Reference: http://gamedev.stackexchange.com/
- Parameters:
qs
- the quaternions to interpolate overweights
- the weights of each individual quaternion inqs
dest
- will hold the result- Returns:
- dest
-
scale
Apply scaling to this quaternion, which results in any vector transformed by this quaternion to change its length by the givenfactor
.- Parameters:
factor
- the scaling factor- Returns:
- this
-
scale
Description copied from interface:Quaternionfc
Apply scaling to this quaternion, which results in any vector transformed by the quaternion to change its length by the givenfactor
, and store the result indest
.- Specified by:
scale
in interfaceQuaternionfc
- Parameters:
factor
- the scaling factordest
- will hold the result- Returns:
- dest
-
scaling
Set this quaternion to represent scaling, which results in a transformed vector to change its length by the givenfactor
.- Parameters:
factor
- the scaling factor- Returns:
- this
-
integrate
Integrate the rotation given by the angular velocity(vx, vy, vz)
around the x, y and z axis, respectively, with respect to the given elapsed time deltadt
and add the differentiate rotation to the rotation represented by this quaternion.This method pre-multiplies the rotation given by
dt
and(vx, vy, vz)
bythis
, so the angular velocities are always relative to the local coordinate system of the rotation represented bythis
quaternion.This method is equivalent to calling:
rotateLocal(dt * vx, dt * vy, dt * vz)
Reference: http://physicsforgames.blogspot.de/
- Parameters:
dt
- the delta timevx
- the angular velocity around the x axisvy
- the angular velocity around the y axisvz
- the angular velocity around the z axis- Returns:
- this
-
integrate
Description copied from interface:Quaternionfc
Integrate the rotation given by the angular velocity(vx, vy, vz)
around the x, y and z axis, respectively, with respect to the given elapsed time deltadt
and add the differentiate rotation to the rotation represented by this quaternion and store the result intodest
.This method pre-multiplies the rotation given by
dt
and(vx, vy, vz)
bythis
, so the angular velocities are always relative to the local coordinate system of the rotation represented bythis
quaternion.This method is equivalent to calling:
rotateLocal(dt * vx, dt * vy, dt * vz, dest)
Reference: http://physicsforgames.blogspot.de/
- Specified by:
integrate
in interfaceQuaternionfc
- Parameters:
dt
- the delta timevx
- the angular velocity around the x axisvy
- the angular velocity around the y axisvz
- the angular velocity around the z axisdest
- will hold the result- Returns:
- dest
-
nlerp
Compute a linear (non-spherical) interpolation ofthis
and the given quaternionq
and store the result inthis
.- Parameters:
q
- the other quaternionfactor
- the interpolation factor. It is between 0.0 and 1.0- Returns:
- this
-
nlerp
Description copied from interface:Quaternionfc
Compute a linear (non-spherical) interpolation ofthis
and the given quaternionq
and store the result indest
.Reference: http://fabiensanglard.net
- Specified by:
nlerp
in interfaceQuaternionfc
- Parameters:
q
- the other quaternionfactor
- the interpolation factor. It is between 0.0 and 1.0dest
- will hold the result- Returns:
- dest
-
nlerp
Interpolate between all of the quaternions given inqs
via non-spherical linear interpolation using the specified interpolation factorsweights
, and store the result indest
.This method will interpolate between each two successive quaternions via
nlerp(Quaternionfc, float)
using their relative interpolation weights.Reference: http://gamedev.stackexchange.com/
- Parameters:
qs
- the quaternions to interpolate overweights
- the weights of each individual quaternion inqs
dest
- will hold the result- Returns:
- dest
-
nlerpIterative
public Quaternionf nlerpIterative(Quaternionfc q, float alpha, float dotThreshold, Quaternionf dest) Description copied from interface:Quaternionfc
Compute linear (non-spherical) interpolations ofthis
and the given quaternionq
iteratively and store the result indest
.This method performs a series of small-step nlerp interpolations to avoid doing a costly spherical linear interpolation, like
slerp
, by subdividing the rotation arc betweenthis
andq
via non-spherical linear interpolations as long as the absolute dot product ofthis
andq
is greater than the givendotThreshold
parameter.Thanks to
@theagentd
at http://www.java-gaming.org/ for providing the code.- Specified by:
nlerpIterative
in interfaceQuaternionfc
- Parameters:
q
- the other quaternionalpha
- the interpolation factor, between 0.0 and 1.0dotThreshold
- the threshold for the dot product ofthis
andq
above which this method performs another iteration of a small-step linear interpolationdest
- will hold the result- Returns:
- dest
-
nlerpIterative
Compute linear (non-spherical) interpolations ofthis
and the given quaternionq
iteratively and store the result inthis
.This method performs a series of small-step nlerp interpolations to avoid doing a costly spherical linear interpolation, like
slerp
, by subdividing the rotation arc betweenthis
andq
via non-spherical linear interpolations as long as the absolute dot product ofthis
andq
is greater than the givendotThreshold
parameter.Thanks to
@theagentd
at http://www.java-gaming.org/ for providing the code.- Parameters:
q
- the other quaternionalpha
- the interpolation factor, between 0.0 and 1.0dotThreshold
- the threshold for the dot product ofthis
andq
above which this method performs another iteration of a small-step linear interpolation- Returns:
- this
-
nlerpIterative
public static Quaternionfc nlerpIterative(Quaternionf[] qs, float[] weights, float dotThreshold, Quaternionf dest) Interpolate between all of the quaternions given inqs
via iterative non-spherical linear interpolation using the specified interpolation factorsweights
, and store the result indest
.This method will interpolate between each two successive quaternions via
nlerpIterative(Quaternionfc, float, float)
using their relative interpolation weights.Reference: http://gamedev.stackexchange.com/
- Parameters:
qs
- the quaternions to interpolate overweights
- the weights of each individual quaternion inqs
dotThreshold
- the threshold for the dot product of each two interpolated quaternions above whichnlerpIterative(Quaternionfc, float, float)
performs another iteration of a small-step linear interpolationdest
- will hold the result- Returns:
- dest
-
lookAlong
Apply a rotation to this quaternion that maps the given direction to the positive Z axis.Because there are multiple possibilities for such a rotation, this method will choose the one that ensures the given up direction to remain parallel to the plane spanned by the
up
anddir
vectors.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!Reference: http://answers.unity3d.com
- Parameters:
dir
- the direction to map to the positive Z axisup
- the vector which will be mapped to a vector parallel to the plane spanned by the givendir
andup
- Returns:
- this
- See Also:
-
lookAlong
Description copied from interface:Quaternionfc
Apply a rotation to this quaternion that maps the given direction to the positive Z axis, and store the result indest
.Because there are multiple possibilities for such a rotation, this method will choose the one that ensures the given up direction to remain parallel to the plane spanned by the
up
anddir
vectors.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!Reference: http://answers.unity3d.com
- Specified by:
lookAlong
in interfaceQuaternionfc
- Parameters:
dir
- the direction to map to the positive Z axisup
- the vector which will be mapped to a vector parallel to the plane spanned by the givendir
andup
dest
- will hold the result- Returns:
- dest
- See Also:
-
lookAlong
Apply a rotation to this quaternion that maps the given direction to the positive Z axis.Because there are multiple possibilities for such a rotation, this method will choose the one that ensures the given up direction to remain parallel to the plane spanned by the
up
anddir
vectors.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!Reference: http://answers.unity3d.com
- Parameters:
dirX
- the x-coordinate of the direction to look alongdirY
- the y-coordinate of the direction to look alongdirZ
- the z-coordinate of the direction to look alongupX
- the x-coordinate of the up vectorupY
- the y-coordinate of the up vectorupZ
- the z-coordinate of the up vector- Returns:
- this
- See Also:
-
lookAlong
public Quaternionf lookAlong(float dirX, float dirY, float dirZ, float upX, float upY, float upZ, Quaternionf dest) Description copied from interface:Quaternionfc
Apply a rotation to this quaternion that maps the given direction to the positive Z axis, and store the result indest
.Because there are multiple possibilities for such a rotation, this method will choose the one that ensures the given up direction to remain parallel to the plane spanned by the
up
anddir
vectors.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!Reference: http://answers.unity3d.com
- Specified by:
lookAlong
in interfaceQuaternionfc
- Parameters:
dirX
- the x-coordinate of the direction to look alongdirY
- the y-coordinate of the direction to look alongdirZ
- the z-coordinate of the direction to look alongupX
- the x-coordinate of the up vectorupY
- the y-coordinate of the up vectorupZ
- the z-coordinate of the up vectordest
- will hold the result- Returns:
- dest
-
rotationTo
public Quaternionf rotationTo(float fromDirX, float fromDirY, float fromDirZ, float toDirX, float toDirY, float toDirZ) Setthis
quaternion to a rotation that rotates thefromDir
vector to point alongtoDir
.Since there can be multiple possible rotations, this method chooses the one with the shortest arc.
Reference: stackoverflow.com
- Parameters:
fromDirX
- the x-coordinate of the direction to rotate into the destination directionfromDirY
- the y-coordinate of the direction to rotate into the destination directionfromDirZ
- the z-coordinate of the direction to rotate into the destination directiontoDirX
- the x-coordinate of the direction to rotate totoDirY
- the y-coordinate of the direction to rotate totoDirZ
- the z-coordinate of the direction to rotate to- Returns:
- this
-
rotationTo
Setthis
quaternion to a rotation that rotates thefromDir
vector to point alongtoDir
.Because there can be multiple possible rotations, this method chooses the one with the shortest arc.
- Parameters:
fromDir
- the starting directiontoDir
- the destination direction- Returns:
- this
- See Also:
-
rotateTo
public Quaternionf rotateTo(float fromDirX, float fromDirY, float fromDirZ, float toDirX, float toDirY, float toDirZ, Quaternionf dest) Description copied from interface:Quaternionfc
Apply a rotation tothis
that rotates thefromDir
vector to point alongtoDir
and store the result indest
.Since there can be multiple possible rotations, this method chooses the one with the shortest arc.
If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!Reference: stackoverflow.com
- Specified by:
rotateTo
in interfaceQuaternionfc
- Parameters:
fromDirX
- the x-coordinate of the direction to rotate into the destination directionfromDirY
- the y-coordinate of the direction to rotate into the destination directionfromDirZ
- the z-coordinate of the direction to rotate into the destination directiontoDirX
- the x-coordinate of the direction to rotate totoDirY
- the y-coordinate of the direction to rotate totoDirZ
- the z-coordinate of the direction to rotate todest
- will hold the result- Returns:
- dest
-
rotateTo
public Quaternionf rotateTo(float fromDirX, float fromDirY, float fromDirZ, float toDirX, float toDirY, float toDirZ) Apply a rotation tothis
that rotates thefromDir
vector to point alongtoDir
.Since there can be multiple possible rotations, this method chooses the one with the shortest arc.
If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Parameters:
fromDirX
- the x-coordinate of the direction to rotate into the destination directionfromDirY
- the y-coordinate of the direction to rotate into the destination directionfromDirZ
- the z-coordinate of the direction to rotate into the destination directiontoDirX
- the x-coordinate of the direction to rotate totoDirY
- the y-coordinate of the direction to rotate totoDirZ
- the z-coordinate of the direction to rotate to- Returns:
- this
- See Also:
-
rotateTo
Description copied from interface:Quaternionfc
Apply a rotation tothis
that rotates thefromDir
vector to point alongtoDir
and store the result indest
.Because there can be multiple possible rotations, this method chooses the one with the shortest arc.
If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Specified by:
rotateTo
in interfaceQuaternionfc
- Parameters:
fromDir
- the starting directiontoDir
- the destination directiondest
- will hold the result- Returns:
- dest
- See Also:
-
rotateTo
Apply a rotation tothis
that rotates thefromDir
vector to point alongtoDir
.Because there can be multiple possible rotations, this method chooses the one with the shortest arc.
If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Parameters:
fromDir
- the starting directiontoDir
- the destination direction- Returns:
- this
- See Also:
-
rotateX
Apply a rotation tothis
quaternion rotating the given radians about the x axis.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Parameters:
angle
- the angle in radians to rotate about the x axis- Returns:
- this
-
rotateX
Description copied from interface:Quaternionfc
Apply a rotation tothis
quaternion rotating the given radians about the x axis and store the result indest
.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Specified by:
rotateX
in interfaceQuaternionfc
- Parameters:
angle
- the angle in radians to rotate about the x axisdest
- will hold the result- Returns:
- dest
-
rotateY
Apply a rotation tothis
quaternion rotating the given radians about the y axis.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Parameters:
angle
- the angle in radians to rotate about the y axis- Returns:
- this
-
rotateY
Description copied from interface:Quaternionfc
Apply a rotation tothis
quaternion rotating the given radians about the y axis and store the result indest
.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Specified by:
rotateY
in interfaceQuaternionfc
- Parameters:
angle
- the angle in radians to rotate about the y axisdest
- will hold the result- Returns:
- dest
-
rotateZ
Apply a rotation tothis
quaternion rotating the given radians about the z axis.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Parameters:
angle
- the angle in radians to rotate about the z axis- Returns:
- this
-
rotateZ
Description copied from interface:Quaternionfc
Apply a rotation tothis
quaternion rotating the given radians about the z axis and store the result indest
.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Specified by:
rotateZ
in interfaceQuaternionfc
- Parameters:
angle
- the angle in radians to rotate about the z axisdest
- will hold the result- Returns:
- dest
-
rotateLocalX
Apply a rotation tothis
quaternion rotating the given radians about the local x axis.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beR * Q
. So when transforming a vectorv
with the new quaternion by usingR * Q * v
, the rotation represented bythis
will be applied first!- Parameters:
angle
- the angle in radians to rotate about the local x axis- Returns:
- this
-
rotateLocalX
Description copied from interface:Quaternionfc
Apply a rotation tothis
quaternion rotating the given radians about the local x axis and store the result indest
.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beR * Q
. So when transforming a vectorv
with the new quaternion by usingR * Q * v
, the rotation represented bythis
will be applied first!- Specified by:
rotateLocalX
in interfaceQuaternionfc
- Parameters:
angle
- the angle in radians to rotate about the local x axisdest
- will hold the result- Returns:
- dest
-
rotateLocalY
Apply a rotation tothis
quaternion rotating the given radians about the local y axis.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beR * Q
. So when transforming a vectorv
with the new quaternion by usingR * Q * v
, the rotation represented bythis
will be applied first!- Parameters:
angle
- the angle in radians to rotate about the local y axis- Returns:
- this
-
rotateLocalY
Description copied from interface:Quaternionfc
Apply a rotation tothis
quaternion rotating the given radians about the local y axis and store the result indest
.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beR * Q
. So when transforming a vectorv
with the new quaternion by usingR * Q * v
, the rotation represented bythis
will be applied first!- Specified by:
rotateLocalY
in interfaceQuaternionfc
- Parameters:
angle
- the angle in radians to rotate about the local y axisdest
- will hold the result- Returns:
- dest
-
rotateLocalZ
Apply a rotation tothis
quaternion rotating the given radians about the local z axis.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beR * Q
. So when transforming a vectorv
with the new quaternion by usingR * Q * v
, the rotation represented bythis
will be applied first!- Parameters:
angle
- the angle in radians to rotate about the local z axis- Returns:
- this
-
rotateLocalZ
Description copied from interface:Quaternionfc
Apply a rotation tothis
quaternion rotating the given radians about the local z axis and store the result indest
.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beR * Q
. So when transforming a vectorv
with the new quaternion by usingR * Q * v
, the rotation represented bythis
will be applied first!- Specified by:
rotateLocalZ
in interfaceQuaternionfc
- Parameters:
angle
- the angle in radians to rotate about the local z axisdest
- will hold the result- Returns:
- dest
-
rotateAxis
Description copied from interface:Quaternionfc
Apply a rotation tothis
quaternion rotating the given radians about the specified axis and store the result indest
.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Specified by:
rotateAxis
in interfaceQuaternionfc
- Parameters:
angle
- the angle in radians to rotate about the specified axisaxisX
- the x coordinate of the rotation axisaxisY
- the y coordinate of the rotation axisaxisZ
- the z coordinate of the rotation axisdest
- will hold the result- Returns:
- dest
-
rotateAxis
Description copied from interface:Quaternionfc
Apply a rotation tothis
quaternion rotating the given radians about the specified axis and store the result indest
.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Specified by:
rotateAxis
in interfaceQuaternionfc
- Parameters:
angle
- the angle in radians to rotate about the specified axisaxis
- the rotation axisdest
- will hold the result- Returns:
- dest
- See Also:
-
rotateAxis
Apply a rotation tothis
quaternion rotating the given radians about the specified axis.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Parameters:
angle
- the angle in radians to rotate about the specified axisaxis
- the rotation axis- Returns:
- this
- See Also:
-
rotateAxis
Apply a rotation tothis
quaternion rotating the given radians about the specified axis.If
Q
isthis
quaternion andR
the quaternion representing the specified rotation, then the new quaternion will beQ * R
. So when transforming a vectorv
with the new quaternion by usingQ * R * v
, the rotation added by this method will be applied first!- Parameters:
angle
- the angle in radians to rotate about the specified axisaxisX
- the x coordinate of the rotation axisaxisY
- the y coordinate of the rotation axisaxisZ
- the z coordinate of the rotation axis- Returns:
- this
- See Also:
-
toString
Return a string representation of this quaternion.This method creates a new
DecimalFormat
on every invocation with the format string "0.000E0;-
". -
toString
Return a string representation of this quaternion by formatting the components with the givenNumberFormat
.- Parameters:
formatter
- theNumberFormat
used to format the quaternion components with- Returns:
- the string representation
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
hashCode
public int hashCode() -
equals
-
difference
Compute the difference betweenthis
and theother
quaternion and store the result inthis
.The difference is the rotation that has to be applied to get from
this
rotation toother
. IfT
isthis
,Q
isother
andD
is the computed difference, then the following equation holds:T * D = Q
It is defined as:
D = T^-1 * Q
, whereT^-1
denotes theinverse
ofT
.- Parameters:
other
- the other quaternion- Returns:
- this
-
difference
Description copied from interface:Quaternionfc
Compute the difference betweenthis
and theother
quaternion and store the result indest
.The difference is the rotation that has to be applied to get from
this
rotation toother
. IfT
isthis
,Q
isother
andD
is the computed difference, then the following equation holds:T * D = Q
It is defined as:
D = T^-1 * Q
, whereT^-1
denotes theinverse
ofT
.- Specified by:
difference
in interfaceQuaternionfc
- Parameters:
other
- the other quaterniondest
- will hold the result- Returns:
- dest
-
positiveX
Description copied from interface:Quaternionfc
Obtain the direction of+X
before the rotation transformation represented bythis
quaternion is applied.This method is equivalent to the following code:
Quaternionf inv = new Quaternionf(this).invert(); inv.transform(dir.set(1, 0, 0));
- Specified by:
positiveX
in interfaceQuaternionfc
- Parameters:
dir
- will hold the direction of+X
- Returns:
- dir
-
normalizedPositiveX
Description copied from interface:Quaternionfc
Obtain the direction of+X
before the rotation transformation represented bythis
normalized quaternion is applied. The quaternion must benormalized
for this method to work.This method is equivalent to the following code:
Quaternionf inv = new Quaternionf(this).conjugate(); inv.transform(dir.set(1, 0, 0));
- Specified by:
normalizedPositiveX
in interfaceQuaternionfc
- Parameters:
dir
- will hold the direction of+X
- Returns:
- dir
-
positiveY
Description copied from interface:Quaternionfc
Obtain the direction of+Y
before the rotation transformation represented bythis
quaternion is applied.This method is equivalent to the following code:
Quaternionf inv = new Quaternionf(this).invert(); inv.transform(dir.set(0, 1, 0));
- Specified by:
positiveY
in interfaceQuaternionfc
- Parameters:
dir
- will hold the direction of+Y
- Returns:
- dir
-
normalizedPositiveY
Description copied from interface:Quaternionfc
Obtain the direction of+Y
before the rotation transformation represented bythis
normalized quaternion is applied. The quaternion must benormalized
for this method to work.This method is equivalent to the following code:
Quaternionf inv = new Quaternionf(this).conjugate(); inv.transform(dir.set(0, 1, 0));
- Specified by:
normalizedPositiveY
in interfaceQuaternionfc
- Parameters:
dir
- will hold the direction of+Y
- Returns:
- dir
-
positiveZ
Description copied from interface:Quaternionfc
Obtain the direction of+Z
before the rotation transformation represented bythis
quaternion is applied.This method is equivalent to the following code:
Quaternionf inv = new Quaternionf(this).invert(); inv.transform(dir.set(0, 0, 1));
- Specified by:
positiveZ
in interfaceQuaternionfc
- Parameters:
dir
- will hold the direction of+Z
- Returns:
- dir
-
normalizedPositiveZ
Description copied from interface:Quaternionfc
Obtain the direction of+Z
before the rotation transformation represented bythis
normalized quaternion is applied. The quaternion must benormalized
for this method to work.This method is equivalent to the following code:
Quaternionf inv = new Quaternionf(this).conjugate(); inv.transform(dir.set(0, 0, 1));
- Specified by:
normalizedPositiveZ
in interfaceQuaternionfc
- Parameters:
dir
- will hold the direction of+Z
- Returns:
- dir
-
conjugateBy
Conjugatethis
by the given quaternionq
by computingq * this * q^-1
.- Parameters:
q
- theQuaternionfc
to conjugatethis
by- Returns:
- this
-
conjugateBy
Conjugatethis
by the given quaternionq
by computingq * this * q^-1
and store the result intodest
.- Specified by:
conjugateBy
in interfaceQuaternionfc
- Parameters:
q
- theQuaternionfc
to conjugatethis
bydest
- will hold the result- Returns:
- dest
-
isFinite
public boolean isFinite()Description copied from interface:Quaternionfc
Determine whether all components are finite floating-point values, that is, they are notNaN
and notinfinity
.- Specified by:
isFinite
in interfaceQuaternionfc
- Returns:
true
if all components are finite floating-point values;false
otherwise
-
equals
Description copied from interface:Quaternionfc
Compare the quaternion components ofthis
quaternion with the given quaternion using the givendelta
and return whether all of them are equal within a maximum difference ofdelta
.Please note that this method is not used by any data structure such as
ArrayList
HashSet
orHashMap
and their operations, such asArrayList.contains(Object)
orHashSet.remove(Object)
, since those data structures only use theObject.equals(Object)
andObject.hashCode()
methods.- Specified by:
equals
in interfaceQuaternionfc
- Parameters:
q
- the other quaterniondelta
- the allowed maximum difference- Returns:
true
whether all of the quaternion components are equal;false
otherwise
-
equals
public boolean equals(float x, float y, float z, float w) - Specified by:
equals
in interfaceQuaternionfc
- Parameters:
x
- the x component to compare toy
- the y component to compare toz
- the z component to compare tow
- the w component to compare to- Returns:
true
if all the quaternion components are equal
-
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-