public class Quaternionf extends Object implements Externalizable
| Modifier and Type | Field and Description |
|---|---|
float |
w
The real/scalar part of the quaternion.
|
float |
x
The first component of the vector part.
|
float |
y
The second component of the vector part.
|
float |
z
The third component of the vector part.
|
| Constructor and Description |
|---|
Quaternionf()
Create a new
Quaternionf and initialize it with (x=0, y=0, z=0, w=1),
where (x, y, z) is the vector part of the quaternion and w is the real/scalar part. |
Quaternionf(float x,
float y,
float z)
Create a new
Quaternionf and initialize its imaginary components to the given values,
and its real part to 1.0. |
Quaternionf(float x,
float y,
float z,
float w)
Create a new
Quaternionf and initialize its components to the given values. |
Quaternionf(Quaternionf source)
Create a new
Quaternionf and initialize its components to the same values as the given Quaternionf. |
| Modifier and Type | Method and Description |
|---|---|
Quaternionf |
add(Quaternionf q2)
Add
q2 to this quaternion. |
Quaternionf |
add(Quaternionf q2,
Quaternionf dest)
Add
q2 to this quaternion and store the result in dest. |
float |
angle()
Return the angle in radians represented by this quaternion rotation.
|
Quaternionf |
conjugate()
Conjugate this quaternion.
|
Quaternionf |
conjugate(Quaternionf dest)
Conjugate this quaternion and store the result in
dest. |
Quaternionf |
difference(Quaternionf other)
Compute the difference between
this and the other quaternion
and store the result in this. |
Quaternionf |
difference(Quaternionf other,
Quaternionf dest)
Compute the difference between
this and the other quaternion
and store the result in dest. |
Quaternionf |
div(Quaternionf b)
Divide
this quaternion by b. |
Quaternionf |
div(Quaternionf b,
Quaternionf dest)
Divide
this quaternion by b and store the result in dest. |
float |
dot(Quaternionf otherQuat)
Return the dot of this quaternion and
otherQuat. |
boolean |
equals(Object obj) |
Matrix3f |
get(Matrix3f dest)
Set the given destination matrix to the rotation represented by
this. |
Matrix4f |
get(Matrix4f dest)
Set the given destination matrix to the rotation represented by
this. |
Quaternionf |
get(Quaternionf dest)
Set the given
Quaternionf to the values of this. |
Vector3f |
getEulerAnglesXYZ(Vector3f eulerAngles)
Get the euler angles in radians in rotation sequence XYZ of this quaternion and store them in the
provided parameter
eulerAngles. |
int |
hashCode() |
Quaternionf |
identity()
Set this quaternion to the identity.
|
Quaternionf |
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 delta dt and add the differentiate rotation to the rotation represented by this quaternion. |
Quaternionf |
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 delta dt and add the differentiate rotation to the rotation represented by this quaternion
and store the result into dest. |
Quaternionf |
invert()
Invert this quaternion and
normalize it. |
Quaternionf |
invert(Quaternionf dest)
Invert this quaternion and store the
normalized result in dest. |
float |
lengthSquared()
Return the square of the length of this quaternion.
|
Quaternionf |
lookRotate(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.
|
Quaternionf |
lookRotate(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 in
dest. |
Quaternionf |
lookRotate(Vector3f dir,
Vector3f up)
Apply a rotation to this quaternion that maps the given direction to the positive Z axis.
|
Quaternionf |
lookRotate(Vector3f dir,
Vector3f up,
Quaternionf dest)
Apply a rotation to this quaternion that maps the given direction to the positive Z axis, and store the result in
dest. |
Quaternionf |
mul(float qx,
float qy,
float qz,
float qw)
Multiply this quaternion by the quaternion represented via (qx, qy, qz, qw).
|
Quaternionf |
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 in
dest. |
Quaternionf |
mul(Quaternionf q)
Multiply this quaternion by
q. |
Quaternionf |
mul(Quaternionf q,
Quaternionf dest)
Multiply this quaternion by
q and store the result in dest. |
Quaternionf |
nlerp(Quaternionf q,
float factor)
Compute a linear (non-spherical) interpolation of
this and the given quaternion q
and store the result in this. |
Quaternionf |
nlerp(Quaternionf q,
float factor,
Quaternionf dest)
Compute a linear (non-spherical) interpolation of
this and the given quaternion q
and store the result in dest. |
Quaternionf |
nlerpIterative(Quaternionf q,
float alpha,
float dotThreshold,
Quaternionf dest)
Compute linear (non-spherical) interpolations of
this and the given quaternion q
iteratively and store the result in dest. |
Quaternionf |
normalize()
Normalize this quaternion.
|
Quaternionf |
normalize(Quaternionf dest)
Normalize this quaternion and store the result in
dest. |
Vector3f |
normalizedPositiveX(Vector3f dir)
Obtain the direction of +X before the rotation transformation represented by
this normalized quaternion is applied. |
Vector3f |
normalizedPositiveY(Vector3f dir)
Obtain the direction of +Y before the rotation transformation represented by
this normalized quaternion is applied. |
Vector3f |
normalizedPositiveZ(Vector3f dir)
Obtain the direction of +Z before the rotation transformation represented by
this normalized quaternion is applied. |
Vector3f |
positiveX(Vector3f dir)
Obtain the direction of +X before the rotation transformation represented by
this quaternion is applied. |
Vector3f |
positiveY(Vector3f dir)
Obtain the direction of +Y before the rotation transformation represented by
this quaternion is applied. |
Vector3f |
positiveZ(Vector3f dir)
Obtain the direction of +Z before the rotation transformation represented by
this quaternion is applied. |
Quaternionf |
premul(float qx,
float qy,
float qz,
float qw)
Pre-multiply this quaternion by the quaternion represented via (qx, qy, qz, qw).
|
Quaternionf |
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 in
dest. |
Quaternionf |
premul(Quaternionf q)
Pre-multiply this quaternion by
q. |
Quaternionf |
premul(Quaternionf q,
Quaternionf dest)
Pre-multiply this quaternion by
q and store the result in dest. |
void |
readExternal(ObjectInput in) |
Quaternionf |
rotate(float angleX,
float angleY,
float angleZ)
Apply a rotation to
this quaternion rotating the given radians about the basis unit axes of the cartesian space. |
Quaternionf |
rotate(float angleX,
float angleY,
float angleZ,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the basis unit axes of the
cartesian space and store the result in dest. |
Quaternionf |
rotateAxis(float angle,
float axisX,
float axisY,
float axisZ)
Apply a rotation to
this quaternion rotating the given radians about the specified axis. |
Quaternionf |
rotateAxis(float angle,
float axisX,
float axisY,
float axisZ,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the specified axis
and store the result in dest. |
Quaternionf |
rotateAxis(float angle,
Vector3f axis)
Apply a rotation to
this quaternion rotating the given radians about the specified axis. |
Quaternionf |
rotateAxis(float angle,
Vector3f axis,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the specified axis
and store the result in dest. |
Quaternionf |
rotateLocal(float angleX,
float angleY,
float angleZ)
Apply a rotation to
this quaternion rotating the given radians about the basis unit axes of the
local coordinate system represented by this quaternion. |
Quaternionf |
rotateLocal(float angleX,
float angleY,
float angleZ,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the basis unit axes of the
local coordinate system represented by this quaternion and store the result in dest. |
Quaternionf |
rotateLocalX(float angle)
Apply a rotation to
this quaternion rotating the given radians about the local x axis. |
Quaternionf |
rotateLocalX(float angle,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the local x axis
and store the result in dest. |
Quaternionf |
rotateLocalY(float angle)
Apply a rotation to
this quaternion rotating the given radians about the local y axis. |
Quaternionf |
rotateLocalY(float angle,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the local y axis
and store the result in dest. |
Quaternionf |
rotateLocalZ(float angle)
Apply a rotation to
this quaternion rotating the given radians about the local z axis. |
Quaternionf |
rotateLocalZ(float angle,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the local z axis
and store the result in dest. |
Quaternionf |
rotateTo(float fromDirX,
float fromDirY,
float fromDirZ,
float toDirX,
float toDirY,
float toDirZ)
Apply a rotation to
this that rotates the fromDir vector to point along toDir. |
Quaternionf |
rotateTo(float fromDirX,
float fromDirY,
float fromDirZ,
float toDirX,
float toDirY,
float toDirZ,
Quaternionf dest)
Apply a rotation to
this that rotates the fromDir vector to point along toDir and
store the result in dest. |
Quaternionf |
rotateTo(Vector3f fromDir,
Vector3f toDir)
Apply a rotation to
this that rotates the fromDir vector to point along toDir. |
Quaternionf |
rotateTo(Vector3f fromDir,
Vector3f toDir,
Quaternionf dest)
Apply a rotation to
this that rotates the fromDir vector to point along toDir and
store the result in dest. |
Quaternionf |
rotateX(float angle)
Apply a rotation to
this quaternion rotating the given radians about the x axis. |
Quaternionf |
rotateX(float angle,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the x axis
and store the result in dest. |
Quaternionf |
rotateXYZ(float angleX,
float angleY,
float angleZ)
Apply a rotation to
this quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles using rotation sequence XYZ. |
Quaternionf |
rotateXYZ(float angleX,
float angleY,
float angleZ,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles using rotation sequence XYZ and store the result in dest. |
Quaternionf |
rotateY(float angle)
Apply a rotation to
this quaternion rotating the given radians about the y axis. |
Quaternionf |
rotateY(float angle,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the y axis
and store the result in dest. |
Quaternionf |
rotateYXZ(float angleZ,
float angleY,
float angleX)
Apply a rotation to
this quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles, using the rotation sequence YXZ. |
Quaternionf |
rotateYXZ(float angleY,
float angleX,
float angleZ,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles, using the rotation sequence YXZ and store the result in dest. |
Quaternionf |
rotateZ(float angle)
Apply a rotation to
this quaternion rotating the given radians about the z axis. |
Quaternionf |
rotateZ(float angle,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the z axis
and store the result in dest. |
Quaternionf |
rotateZYX(float angleZ,
float angleY,
float angleX)
Apply a rotation to
this quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles, using the rotation sequence ZYX. |
Quaternionf |
rotateZYX(float angleZ,
float angleY,
float angleX,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles, using the rotation sequence ZYX and store the result in dest. |
Quaternionf |
rotation(float angleX,
float angleY,
float angleZ)
Set this quaternion to represent a rotation of the given angles in radians about the basis unit axes of the cartesian space.
|
Quaternionf |
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.
|
Quaternionf |
rotationAxis(float angle,
Vector3f axis)
Set this quaternion to a rotation of the given angle in radians about the supplied axis.
|
Quaternionf |
rotationTo(float fromDirX,
float fromDirY,
float fromDirZ,
float toDirX,
float toDirY,
float toDirZ)
Set
this quaternion to a rotation that rotates the fromDir vector to point along toDir. |
Quaternionf |
rotationTo(Vector3f fromDir,
Vector3f toDir)
Set
this quaternion to a rotation that rotates the fromDir vector to point along toDir. |
Quaternionf |
rotationX(float angle)
Set this quaternion to represent a rotation of the given radians about the x axis.
|
Quaternionf |
rotationXYZ(float angleX,
float angleY,
float angleZ)
Set this quaternion from the supplied euler angles (in radians) with rotation order XYZ.
|
Quaternionf |
rotationY(float angle)
Set this quaternion to represent a rotation of the given radians about the y axis.
|
Quaternionf |
rotationYXZ(float angleY,
float angleX,
float angleZ)
Set this quaternion from the supplied euler angles (in radians) with rotation order YXZ.
|
Quaternionf |
rotationZ(float angle)
Set this quaternion to represent a rotation of the given radians about the z axis.
|
Quaternionf |
rotationZYX(float angleZ,
float angleY,
float angleX)
Set this quaternion from the supplied euler angles (in radians) with rotation order ZYX.
|
Quaternionf |
scale(float factor)
Scale the rotation represented by this quaternion by the given
factor using sperical linear interpolation. |
Quaternionf |
scale(float factor,
Quaternionf dest)
Scale the rotation represented by this quaternion by the given
factor using sperical linear interpolation, and store the result in dest. |
Quaternionf |
set(float x,
float y,
float z)
Set the x, y and z components of this quaternion to the given values.
|
Quaternionf |
set(float x,
float y,
float z,
float w)
Set this quaternion to the given values.
|
Quaternionf |
set(Quaternionf q)
Set this quaternion to be a copy of q.
|
Quaternionf |
setAngleAxis(double angle,
double x,
double y,
double z)
Set this quaternion to a rotation equivalent to the supplied axis and
angle (in radians).
|
Quaternionf |
setAngleAxis(float angle,
float x,
float y,
float z)
Set this quaternion to a rotation equivalent to the supplied axis and
angle (in radians).
|
Quaternionf |
setFromNormalized(Matrix3f mat)
Set this quaternion to be a representation of the rotational component of the given matrix.
|
Quaternionf |
setFromNormalized(Matrix4f mat)
Set this quaternion to be a representation of the rotational component of the given matrix.
|
Quaternionf |
setFromUnnormalized(Matrix3f mat)
Set this quaternion to be a representation of the rotational component of the given matrix.
|
Quaternionf |
setFromUnnormalized(Matrix4f mat)
Set this quaternion to be a representation of the rotational component of the given matrix.
|
Quaternionf |
slerp(Quaternionf target,
float alpha)
Interpolate between
this quaternion and the specified
target using sperical linear interpolation using the specified interpolation factor alpha. |
Quaternionf |
slerp(Quaternionf target,
float alpha,
Quaternionf dest)
Interpolate between
this quaternion and the specified
target using sperical linear interpolation using the specified interpolation factor alpha,
and store the result in dest. |
String |
toString()
Return a string representation of this quaternion.
|
String |
toString(NumberFormat formatter)
Return a string representation of this quaternion by formatting the components with the given
NumberFormat. |
Vector3f |
transform(Vector3f vec)
Transform the given vector by this quaternion.
|
Vector3f |
transform(Vector3f vec,
Vector3f dest)
Transform the given vector by this quaternion and store the result in
dest. |
Vector4f |
transform(Vector4f vec)
Transform the given vector by this quaternion.
|
Vector4f |
transform(Vector4f vec,
Vector4f dest)
Transform the given vector by this quaternion and store the result in
dest. |
void |
writeExternal(ObjectOutput out) |
public float x
public float y
public float z
public float w
public Quaternionf()
Quaternionf and initialize it with (x=0, y=0, z=0, w=1),
where (x, y, z) is the vector part of the quaternion and w is the real/scalar part.public Quaternionf(float x,
float y,
float z,
float w)
Quaternionf and initialize its components to the given values.x - the first component of the imaginary party - the second component of the imaginary partz - the third component of the imaginary partw - the real partpublic Quaternionf(float x,
float y,
float z)
Quaternionf and initialize its imaginary components to the given values,
and its real part to 1.0.x - the first component of the imaginary party - the second component of the imaginary partz - the third component of the imaginary partpublic Quaternionf(Quaternionf source)
Quaternionf and initialize its components to the same values as the given Quaternionf.source - the Quaternionf to take the component values frompublic Quaternionf normalize()
public Quaternionf normalize(Quaternionf dest)
dest.dest - will hold the resultpublic Quaternionf add(Quaternionf q2)
q2 to this quaternion.q2 - the quaternion to add to thispublic Quaternionf add(Quaternionf q2, Quaternionf dest)
q2 to this quaternion and store the result in dest.q2 - the quaternion to add to thisdest - will hold the resultpublic float dot(Quaternionf otherQuat)
otherQuat.otherQuat - the other quaternionpublic float angle()
public Matrix3f get(Matrix3f dest)
this.dest - the matrix to write the rotation intopublic Matrix4f get(Matrix4f dest)
this.dest - the matrix to write the rotation intopublic Quaternionf get(Quaternionf dest)
Quaternionf to the values of this.dest - the Quaternionf to setset(Quaternionf)public Quaternionf set(float x, float y, float z, float w)
x - the new value of xy - the new value of yz - the new value of zw - the new value of wpublic Quaternionf set(float x, float y, float z)
x - the new value of xy - the new value of yz - the new value of zpublic Quaternionf set(Quaternionf q)
q - the Quaternionf to copypublic Quaternionf setAngleAxis(float angle, float x, float y, float z)
This method assumes that the given rotation axis (x, y, z) is already normalized
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 axispublic Quaternionf setAngleAxis(double angle, double x, double y, double z)
This method assumes that the given rotation axis (x, y, z) is already normalized
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 axispublic Quaternionf rotationAxis(float angle, float axisX, float axisY, float axisZ)
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 axispublic Quaternionf rotationAxis(float angle, Vector3f axis)
angle - the rotation angle in radiansaxis - the axis to rotate aboutrotationAxis(float, float, float, float)public Quaternionf rotation(float angleX, float angleY, float angleZ)
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 axispublic Quaternionf rotationX(float angle)
angle - the angle in radians to rotate about the x axispublic Quaternionf rotationY(float angle)
angle - the angle in radians to rotate about the y axispublic Quaternionf rotationZ(float angle)
angle - the angle in radians to rotate about the z axispublic Quaternionf setFromUnnormalized(Matrix4f mat)
This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.
mat - the matrix whose rotational component is used to set this quaternionpublic Quaternionf setFromNormalized(Matrix4f mat)
This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.
mat - the matrix whose rotational component is used to set this quaternionpublic Quaternionf setFromUnnormalized(Matrix3f mat)
This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.
mat - the matrix whose rotational component is used to set this quaternionpublic Quaternionf setFromNormalized(Matrix3f mat)
This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.
mat - the matrix whose rotational component is used to set this quaternionpublic Quaternionf mul(Quaternionf q)
q.
If T is this and Q is the given
quaternion, then the resulting quaternion R 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 by T.
q - the quaternion to multiply this bypublic Quaternionf mul(Quaternionf q, Quaternionf dest)
q and store the result in dest.
If T is this and Q is the given
quaternion, then the resulting quaternion R 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 by T.
q - the quaternion to multiply this bydest - will hold the resultpublic Quaternionf mul(float qx, float qy, float qz, float qw)
If T is this and Q is the given
quaternion, then the resulting quaternion R 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 by T.
qx - the x component of the quaternion to multiply this byqy - the y component of the quaternion to multiply this byqz - the z component of the quaternion to multiply this byqw - the w component of the quaternion to multiply this bypublic Quaternionf mul(float qx, float qy, float qz, float qw, Quaternionf dest)
dest.
If T is this and Q is the given
quaternion, then the resulting quaternion R 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 by T.
qx - the x component of the quaternion to multiply this byqy - the y component of the quaternion to multiply this byqz - the z component of the quaternion to multiply this byqw - the w component of the quaternion to multiply this bydest - will hold the resultpublic Quaternionf premul(Quaternionf q)
q.
If T is this and Q is the given quaternion, then the resulting quaternion R is:
R = Q * T
So, this method uses pre-multiplication, resulting in a vector to be transformed by T first, and then by Q.
q - the quaternion to pre-multiply this bypublic Quaternionf premul(Quaternionf q, Quaternionf dest)
q and store the result in dest.
If T is this and Q is the given quaternion, then the resulting quaternion R is:
R = Q * T
So, this method uses pre-multiplication, resulting in a vector to be transformed by T first, and then by Q.
q - the quaternion to pre-multiply this bydest - will hold the resultpublic Quaternionf premul(float qx, float qy, float qz, float qw)
If T is this and Q is the given quaternion, then the resulting quaternion R is:
R = Q * T
So, this method uses pre-multiplication, resulting in a vector to be transformed by T first, and then by Q.
qx - the x component of the quaternion to multiply this byqy - the y component of the quaternion to multiply this byqz - the z component of the quaternion to multiply this byqw - the w component of the quaternion to multiply this bypublic Quaternionf premul(float qx, float qy, float qz, float qw, Quaternionf dest)
dest.
If T is this and Q is the given quaternion, then the resulting quaternion R is:
R = Q * T
So, this method uses pre-multiplication, resulting in a vector to be transformed by T first, and then by Q.
qx - the x component of the quaternion to multiply this byqy - the y component of the quaternion to multiply this byqz - the z component of the quaternion to multiply this byqw - the w component of the quaternion to multiply this bydest - will hold the resultpublic Vector3f transform(Vector3f vec)
vec - the vector to transformpublic Vector4f transform(Vector4f vec)
Only the first three components of the given 4D vector are being used and modified.
vec - the vector to transformpublic Vector3f transform(Vector3f vec, Vector3f dest)
dest.
This will apply the rotation described by this quaternion to the given vector.vec - the vector to transformdest - will hold the resultpublic Vector4f transform(Vector4f vec, Vector4f dest)
dest.
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.
vec - the vector to transformdest - will hold the resultpublic Quaternionf invert(Quaternionf dest)
normalized result in dest.
If this quaternion is already normalized, then conjugate(Quaternionf) should be used instead.
dest - will hold the resultconjugate(Quaternionf)public Quaternionf invert()
normalize it.
If this quaternion is already normalized, then conjugate() should be used instead.
conjugate()public Quaternionf div(Quaternionf b, Quaternionf dest)
this quaternion by b and store the result in dest.
The division expressed using the inverse is performed in the following way:
dest = this * b^-1, where b^-1 is the inverse of b.
b - the Quaternionf to divide this bydest - will hold the resultpublic Quaternionf div(Quaternionf b)
this quaternion by b.
The division expressed using the inverse is performed in the following way:
this = this * b^-1, where b^-1 is the inverse of b.
b - the Quaternionf to divide this bypublic Quaternionf conjugate()
public Quaternionf conjugate(Quaternionf dest)
dest.dest - will hold the resultpublic Quaternionf identity()
public Quaternionf rotateXYZ(float angleX, float angleY, float angleZ)
this quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles using rotation sequence XYZ.
This method is equivalent to calling: rotateX(angleX).rotateY(angleY).rotateZ(angleZ)
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
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 axispublic Quaternionf rotateXYZ(float angleX, float angleY, float angleZ, Quaternionf dest)
this quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles using rotation sequence XYZ and store the result in dest.
This method is equivalent to calling: rotateX(angleX, dest).rotateY(angleY).rotateZ(angleZ)
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
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 resultpublic Quaternionf rotateZYX(float angleZ, float angleY, float angleX)
this quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles, using the rotation sequence ZYX.
This method is equivalent to calling: rotateZ(angleZ).rotateY(angleY).rotateX(angleX)
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
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 axispublic Quaternionf rotateZYX(float angleZ, float angleY, float angleX, Quaternionf dest)
this quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles, using the rotation sequence ZYX and store the result in dest.
This method is equivalent to calling: rotateZ(angleZ, dest).rotateY(angleY).rotateX(angleX)
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
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 resultpublic Quaternionf rotateYXZ(float angleZ, float angleY, float angleX)
this quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles, using the rotation sequence YXZ.
This method is equivalent to calling: rotateY(angleY).rotateX(angleX).rotateZ(angleZ)
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
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 axispublic Quaternionf rotateYXZ(float angleY, float angleX, float angleZ, Quaternionf dest)
this quaternion rotating the given radians about the cartesian base unit axes,
called the euler angles, using the rotation sequence YXZ and store the result in dest.
This method is equivalent to calling: rotateY(angleY, dest).rotateX(angleX).rotateZ(angleZ)
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
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 resultpublic Vector3f getEulerAnglesXYZ(Vector3f eulerAngles)
eulerAngles.eulerAngles - will hold the euler angles in radianspublic float lengthSquared()
public Quaternionf rotationXYZ(float angleX, float angleY, float angleZ)
This method is equivalent to calling: rotationX(angleX).rotateY(angleY).rotateZ(angleZ)
Reference: this stackexchange answer
angleX - the angle in radians to rotate about xangleY - the angle in radians to rotate about yangleZ - the angle in radians to rotate about zpublic Quaternionf rotationZYX(float angleZ, float angleY, float angleX)
This method is equivalent to calling: rotationZ(angleZ).rotateY(angleY).rotateX(angleX)
Reference: this stackexchange answer
angleX - the angle in radians to rotate about xangleY - the angle in radians to rotate about yangleZ - the angle in radians to rotate about zpublic Quaternionf rotationYXZ(float angleY, float angleX, float angleZ)
This method is equivalent to calling: rotationY(angleY).rotateX(angleX).rotateZ(angleZ)
Reference: https://en.wikipedia.org
angleY - the angle in radians to rotate about yangleX - the angle in radians to rotate about xangleZ - the angle in radians to rotate about zpublic Quaternionf slerp(Quaternionf target, float alpha)
this quaternion and the specified
target using sperical linear interpolation using the specified interpolation factor alpha.
This method resorts to non-spherical linear interpolation when the absolute dot product of this and target is
below 1E-6f.
target - the target of the interpolation, which should be reached with alpha = 1.0alpha - the interpolation factor, within [0..1]public Quaternionf slerp(Quaternionf target, float alpha, Quaternionf dest)
this quaternion and the specified
target using sperical linear interpolation using the specified interpolation factor alpha,
and store the result in dest.
This method resorts to non-spherical linear interpolation when the absolute dot product of this and target is
below 1E-6f.
Reference: http://fabiensanglard.net
target - the target of the interpolation, which should be reached with alpha = 1.0alpha - the interpolation factor, within [0..1]dest - will hold the resultpublic Quaternionf scale(float factor)
factor using sperical linear interpolation.
This method is equivalent to performing a spherical linear interpolation between the unit quaternion and this,
and thus equivalent to calling: new Quaterniond().slerp(this, factor)
Reference: http://fabiensanglard.net
factor - the scaling/interpolation factor, within [0..1]slerp(Quaternionf, float)public Quaternionf scale(float factor, Quaternionf dest)
factor using sperical linear interpolation, and store the result in dest.
This method is equivalent to performing a spherical linear interpolation between the unit quaternion and this,
and thus equivalent to calling: new Quaternionf().slerp(this, factor, dest)
Reference: http://fabiensanglard.net
factor - the scaling/interpolation factor, within [0..1]dest - will hold the resultslerp(Quaternionf, float, Quaternionf)public Quaternionf integrate(float dt, float vx, float vy, float vz)
(vx, vy, vz) around the x, y and z axis, respectively,
with respect to the given elapsed time delta dt 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) by this, so
the angular velocities are always relative to the local coordinate system of the rotation represented by this quaternion.
This method is equivalent to calling: rotateLocal(dt * vx, dt * vy, dt * vz)
Reference: http://physicsforgames.blogspot.de/
dt - the delta timevx - the angular velocity around the x axisvy - the angular velocity around the y axisvz - the angular velocity around the z axisrotateLocal(float, float, float)public Quaternionf integrate(float dt, float vx, float vy, float vz, Quaternionf dest)
(vx, vy, vz) around the x, y and z axis, respectively,
with respect to the given elapsed time delta dt and add the differentiate rotation to the rotation represented by this quaternion
and store the result into dest.
This method pre-multiplies the rotation given by dt and (vx, vy, vz) by this, so
the angular velocities are always relative to the local coordinate system of the rotation represented by this quaternion.
This method is equivalent to calling: rotateLocal(dt * vx, dt * vy, dt * vz, dest)
Reference: http://physicsforgames.blogspot.de/
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 resultrotateLocal(float, float, float, Quaternionf)public Quaternionf nlerp(Quaternionf q, float factor)
this and the given quaternion q
and store the result in this.q - the other quaternionfactor - the interpolation factor. It is between 0.0 and 1.0public Quaternionf nlerp(Quaternionf q, float factor, Quaternionf dest)
this and the given quaternion q
and store the result in dest.
Reference: http://fabiensanglard.net
q - the other quaternionfactor - the interpolation factor. It is between 0.0 and 1.0dest - will hold the resultpublic Quaternionf nlerpIterative(Quaternionf q, float alpha, float dotThreshold, Quaternionf dest)
this and the given quaternion q
iteratively and store the result in dest.
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 between this and q via non-spherical linear interpolations as long as
the absolute dot product of this and q is greater than the given dotThreshold parameter.
Thanks to @theagentd at http://www.java-gaming.org/ for providing the code.
q - the other quaternionalpha - the interpolation factor, between 0.0 and 1.0dotThreshold - the threshold for the dot product of this and q above which this method performs another iteration
of a small-step linear interpolationdest - will hold the resultpublic Quaternionf lookRotate(Vector3f dir, Vector3f up)
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 and dir vectors.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
Reference: http://answers.unity3d.com
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 given dir and uplookRotate(float, float, float, float, float, float, Quaternionf)public Quaternionf lookRotate(Vector3f dir, Vector3f up, Quaternionf dest)
dest.
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 and dir vectors.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
Reference: http://answers.unity3d.com
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 given dir and updest - will hold the resultlookRotate(float, float, float, float, float, float, Quaternionf)public Quaternionf lookRotate(float dirX, float dirY, float dirZ, float upX, float upY, float upZ)
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 and dir vectors.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
Reference: http://answers.unity3d.com
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 vectorlookRotate(float, float, float, float, float, float, Quaternionf)public Quaternionf lookRotate(float dirX, float dirY, float dirZ, float upX, float upY, float upZ, Quaternionf dest)
dest.
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 and dir vectors.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
Reference: http://answers.unity3d.com
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 resultpublic Quaternionf rotationTo(float fromDirX, float fromDirY, float fromDirZ, float toDirX, float toDirY, float toDirZ)
this quaternion to a rotation that rotates the fromDir vector to point along toDir.
Since there can be multiple possible rotations, this method chooses the one with the shortest arc.
Reference: stackoverflow.com
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 topublic Quaternionf rotationTo(Vector3f fromDir, Vector3f toDir)
this quaternion to a rotation that rotates the fromDir vector to point along toDir.
Because there can be multiple possible rotations, this method chooses the one with the shortest arc.
fromDir - the starting directiontoDir - the destination directionrotationTo(float, float, float, float, float, float)public Quaternionf rotateTo(float fromDirX, float fromDirY, float fromDirZ, float toDirX, float toDirY, float toDirZ, Quaternionf dest)
this that rotates the fromDir vector to point along toDir and
store the result in dest.
Since there can be multiple possible rotations, this method chooses the one with the shortest arc.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
Reference: stackoverflow.com
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 resultpublic Quaternionf rotateTo(float fromDirX, float fromDirY, float fromDirZ, float toDirX, float toDirY, float toDirZ)
this that rotates the fromDir vector to point along toDir.
Since there can be multiple possible rotations, this method chooses the one with the shortest arc.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
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 torotateTo(float, float, float, float, float, float, Quaternionf)public Quaternionf rotateTo(Vector3f fromDir, Vector3f toDir, Quaternionf dest)
this that rotates the fromDir vector to point along toDir and
store the result in dest.
Because there can be multiple possible rotations, this method chooses the one with the shortest arc.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
fromDir - the starting directiontoDir - the destination directiondest - will hold the resultrotateTo(float, float, float, float, float, float, Quaternionf)public Quaternionf rotateTo(Vector3f fromDir, Vector3f toDir)
this that rotates the fromDir vector to point along toDir.
Because there can be multiple possible rotations, this method chooses the one with the shortest arc.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
fromDir - the starting directiontoDir - the destination directionrotateTo(float, float, float, float, float, float, Quaternionf)public Quaternionf rotate(float angleX, float angleY, float angleZ)
this quaternion rotating the given radians about the basis unit axes of the cartesian space.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
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 axisrotate(float, float, float, Quaternionf)public Quaternionf rotate(float angleX, float angleY, float angleZ, Quaternionf dest)
this quaternion rotating the given radians about the basis unit axes of the
cartesian space and store the result in dest.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
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 resultrotate(float, float, float)public Quaternionf rotateLocal(float angleX, float angleY, float angleZ)
this quaternion rotating the given radians about the basis unit axes of the
local coordinate system represented by this quaternion.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be R * Q. So when transforming a
vector v with the new quaternion by using R * Q * v, the
rotation represented by this will be applied first!
angleX - the angle in radians to rotate about the local x axisangleY - the angle in radians to rotate about the local y axisangleZ - the angle in radians to rotate about the local z axisrotateLocal(float, float, float, Quaternionf)public Quaternionf rotateLocal(float angleX, float angleY, float angleZ, Quaternionf dest)
this quaternion rotating the given radians about the basis unit axes of the
local coordinate system represented by this quaternion and store the result in dest.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be R * Q. So when transforming a
vector v with the new quaternion by using R * Q * v, the
rotation represented by this will be applied first!
angleX - the angle in radians to rotate about the local x axisangleY - the angle in radians to rotate about the local y axisangleZ - the angle in radians to rotate about the local z axisdest - will hold the resultrotateLocal(float, float, float)public Quaternionf rotateX(float angle)
this quaternion rotating the given radians about the x axis.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
angle - the angle in radians to rotate about the x axisrotate(float, float, float, Quaternionf)public Quaternionf rotateX(float angle, Quaternionf dest)
this quaternion rotating the given radians about the x axis
and store the result in dest.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
angle - the angle in radians to rotate about the x axisdest - will hold the resultrotate(float, float, float, Quaternionf)public Quaternionf rotateY(float angle)
this quaternion rotating the given radians about the y axis.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
angle - the angle in radians to rotate about the y axisrotate(float, float, float, Quaternionf)public Quaternionf rotateY(float angle, Quaternionf dest)
this quaternion rotating the given radians about the y axis
and store the result in dest.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
angle - the angle in radians to rotate about the y axisdest - will hold the resultrotate(float, float, float, Quaternionf)public Quaternionf rotateZ(float angle)
this quaternion rotating the given radians about the z axis.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
angle - the angle in radians to rotate about the z axisrotate(float, float, float, Quaternionf)public Quaternionf rotateZ(float angle, Quaternionf dest)
this quaternion rotating the given radians about the z axis
and store the result in dest.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
angle - the angle in radians to rotate about the z axisdest - will hold the resultrotate(float, float, float, Quaternionf)public Quaternionf rotateLocalX(float angle)
this quaternion rotating the given radians about the local x axis.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be R * Q. So when transforming a
vector v with the new quaternion by using R * Q * v, the
rotation represented by this will be applied first!
angle - the angle in radians to rotate about the local x axispublic Quaternionf rotateLocalX(float angle, Quaternionf dest)
this quaternion rotating the given radians about the local x axis
and store the result in dest.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be R * Q. So when transforming a
vector v with the new quaternion by using R * Q * v, the
rotation represented by this will be applied first!
angle - the angle in radians to rotate about the local x axisdest - will hold the resultpublic Quaternionf rotateLocalY(float angle)
this quaternion rotating the given radians about the local y axis.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be R * Q. So when transforming a
vector v with the new quaternion by using R * Q * v, the
rotation represented by this will be applied first!
angle - the angle in radians to rotate about the local y axispublic Quaternionf rotateLocalY(float angle, Quaternionf dest)
this quaternion rotating the given radians about the local y axis
and store the result in dest.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be R * Q. So when transforming a
vector v with the new quaternion by using R * Q * v, the
rotation represented by this will be applied first!
angle - the angle in radians to rotate about the local y axisdest - will hold the resultpublic Quaternionf rotateLocalZ(float angle)
this quaternion rotating the given radians about the local z axis.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be R * Q. So when transforming a
vector v with the new quaternion by using R * Q * v, the
rotation represented by this will be applied first!
angle - the angle in radians to rotate about the local z axispublic Quaternionf rotateLocalZ(float angle, Quaternionf dest)
this quaternion rotating the given radians about the local z axis
and store the result in dest.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be R * Q. So when transforming a
vector v with the new quaternion by using R * Q * v, the
rotation represented by this will be applied first!
angle - the angle in radians to rotate about the local z axisdest - will hold the resultpublic Quaternionf rotateAxis(float angle, float axisX, float axisY, float axisZ, Quaternionf dest)
this quaternion rotating the given radians about the specified axis
and store the result in dest.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
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 resultpublic Quaternionf rotateAxis(float angle, Vector3f axis, Quaternionf dest)
this quaternion rotating the given radians about the specified axis
and store the result in dest.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
angle - the angle in radians to rotate about the specified axisaxis - the rotation axisdest - will hold the resultrotateAxis(float, float, float, float, Quaternionf)public Quaternionf rotateAxis(float angle, Vector3f axis)
this quaternion rotating the given radians about the specified axis.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
angle - the angle in radians to rotate about the specified axisaxis - the rotation axisrotateAxis(float, float, float, float, Quaternionf)public Quaternionf rotateAxis(float angle, float axisX, float axisY, float axisZ)
this quaternion rotating the given radians about the specified axis.
If Q is this quaternion and R the quaternion representing the
specified rotation, then the new quaternion will be Q * R. So when transforming a
vector v with the new quaternion by using Q * R * v, the
rotation added by this method will be applied first!
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 axisrotateAxis(float, float, float, float, Quaternionf)public String toString()
This method creates a new DecimalFormat on every invocation with the format string " 0.000E0;-".
public String toString(NumberFormat formatter)
NumberFormat.formatter - the NumberFormat used to format the quaternion components withpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic Quaternionf difference(Quaternionf other)
this and the other quaternion
and store the result in this.
The difference is the rotation that has to be applied to get from
this rotation to other. If T is this, Q
is other and D is the computed difference, then the following equation holds:
T * D = Q
It is defined as: D = T^-1 * Q, where T^-1 denotes the inverse of T.
other - the other quaternionpublic Quaternionf difference(Quaternionf other, Quaternionf dest)
this and the other quaternion
and store the result in dest.
The difference is the rotation that has to be applied to get from
this rotation to other. If T is this, Q
is other and D is the computed difference, then the following equation holds:
T * D = Q
It is defined as: D = T^-1 * Q, where T^-1 denotes the inverse of T.
other - the other quaterniondest - will hold the resultpublic Vector3f positiveX(Vector3f dir)
this quaternion is applied.
This method is equivalent to the following code:
Quaternionf inv = new Quaternionf(this).invert(); inv.transform(dir.set(1, 0, 0));
dir - will hold the direction of +Xpublic Vector3f normalizedPositiveX(Vector3f dir)
this normalized quaternion is applied.
The quaternion must be normalized 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));
dir - will hold the direction of +Xpublic Vector3f positiveY(Vector3f dir)
this quaternion is applied.
This method is equivalent to the following code:
Quaternionf inv = new Quaternionf(this).invert(); inv.transform(dir.set(0, 1, 0));
dir - will hold the direction of +Ypublic Vector3f normalizedPositiveY(Vector3f dir)
this normalized quaternion is applied.
The quaternion must be normalized 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));
dir - will hold the direction of +Ypublic Vector3f positiveZ(Vector3f dir)
this quaternion is applied.
This method is equivalent to the following code:
Quaternionf inv = new Quaternionf(this).invert(); inv.transform(dir.set(0, 0, 1));
dir - will hold the direction of +Zpublic Vector3f normalizedPositiveZ(Vector3f dir)
this normalized quaternion is applied.
The quaternion must be normalized 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));
dir - will hold the direction of +ZCopyright © 2015–2016 JOML. All rights reserved.