public interface Quaternionfc
| Modifier and Type | Method and Description |
|---|---|
Quaternionf |
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 in dest. |
Quaternionf |
add(Quaternionfc 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(Quaternionf dest)
Conjugate this quaternion and store the result in
dest. |
Quaternionf |
difference(Quaternionf other,
Quaternionf dest)
Compute the difference between
this and the other quaternion
and store the result in dest. |
Quaternionf |
div(Quaternionfc b,
Quaternionf dest)
Divide
this quaternion by b and store the result in dest. |
AxisAngle4f |
get(AxisAngle4f dest)
Set the given
AxisAngle4f to represent the rotation of
this quaternion. |
Matrix3d |
get(Matrix3d dest)
Set the given destination matrix to the rotation represented by
this. |
Matrix3f |
get(Matrix3f dest)
Set the given destination matrix to the rotation represented by
this. |
Matrix4d |
get(Matrix4d 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. |
Matrix4x3d |
get(Matrix4x3d dest)
Set the given destination matrix to the rotation represented by
this. |
Matrix4x3f |
get(Matrix4x3f dest)
Set the given destination matrix to the rotation represented by
this. |
Quaterniond |
get(Quaterniond dest)
Set the given
Quaterniond to the values of this. |
Quaternionf |
get(Quaternionf dest)
Set the given
Quaternionf to the values of this. |
ByteBuffer |
getAsMatrix3f(ByteBuffer dest)
Store the 3x3 float matrix representation of
this quaternion in column-major order into the given ByteBuffer. |
FloatBuffer |
getAsMatrix3f(FloatBuffer dest)
Store the 3x3 float matrix representation of
this quaternion in column-major order into the given FloatBuffer. |
ByteBuffer |
getAsMatrix4f(ByteBuffer dest)
Store the 4x4 float matrix representation of
this quaternion in column-major order into the given ByteBuffer. |
FloatBuffer |
getAsMatrix4f(FloatBuffer dest)
Store the 4x4 float matrix representation of
this quaternion in column-major order into the given FloatBuffer. |
ByteBuffer |
getAsMatrix4x3f(ByteBuffer dest)
Store the 4x3 float matrix representation of
this quaternion in column-major order into the given ByteBuffer. |
FloatBuffer |
getAsMatrix4x3f(FloatBuffer dest)
Store the 4x3 float matrix representation of
this quaternion in column-major order into the given FloatBuffer. |
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. |
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(Quaternionf dest)
Invert this quaternion and store the
normalized result in dest. |
float |
lengthSquared()
Return the square of the length of this quaternion.
|
Quaternionf |
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 in
dest. |
Quaternionf |
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 in
dest. |
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(Quaternionfc q,
Quaternionf dest)
Multiply this quaternion by
q and store the result in dest. |
Quaternionf |
nlerp(Quaternionfc 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(Quaternionfc 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(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,
Quaternionf dest)
Pre-multiply this quaternion by the quaternion represented via
(qx, qy, qz, qw) and store the result in dest. |
Quaternionf |
premul(Quaternionfc q,
Quaternionf dest)
Pre-multiply this quaternion by
q and store the result in dest. |
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,
Vector3fc axis,
Quaternionf dest)
Apply a rotation to
this quaternion rotating the given radians about the specified axis
and store the result in dest. |
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,
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,
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,
Quaternionf dest)
Apply a rotation to
this that rotates the fromDir vector to point along toDir and
store the result in dest. |
Quaternionf |
rotateTo(Vector3fc fromDir,
Vector3fc 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,
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,
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,
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 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,
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,
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 |
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 given
factor, and store the result in dest. |
Quaternionf |
slerp(Quaternionfc target,
float alpha,
Quaternionf dest)
|
Vector3f |
transform(float x,
float y,
float z,
Vector3f dest)
Transform the given vector
(x, y, z) by this quaternion and store the result in dest. |
Vector4f |
transform(float x,
float y,
float z,
Vector4f dest)
Transform the given vector
(x, y, z) by this quaternion and store the result in dest. |
Vector3f |
transform(Vector3f vec)
Transform the given vector by this quaternion.
|
Vector3f |
transform(Vector3fc 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(Vector4fc vec,
Vector4f dest)
Transform the given vector by this quaternion and store the result in
dest. |
Vector3f |
transformPositiveX(Vector3f dest)
Transform the vector
(1, 0, 0) by this quaternion. |
Vector4f |
transformPositiveX(Vector4f dest)
Transform the vector
(1, 0, 0) by this quaternion. |
Vector3f |
transformPositiveY(Vector3f dest)
Transform the vector
(0, 1, 0) by this quaternion. |
Vector4f |
transformPositiveY(Vector4f dest)
Transform the vector
(0, 1, 0) by this quaternion. |
Vector3f |
transformPositiveZ(Vector3f dest)
Transform the vector
(0, 0, 1) by this quaternion. |
Vector4f |
transformPositiveZ(Vector4f dest)
Transform the vector
(0, 0, 1) by this quaternion. |
Vector3f |
transformUnitPositiveX(Vector3f dest)
Transform the vector
(1, 0, 0) by this unit quaternion. |
Vector4f |
transformUnitPositiveX(Vector4f dest)
Transform the vector
(1, 0, 0) by this unit quaternion. |
Vector3f |
transformUnitPositiveY(Vector3f dest)
Transform the vector
(0, 1, 0) by this unit quaternion. |
Vector4f |
transformUnitPositiveY(Vector4f dest)
Transform the vector
(0, 1, 0) by this unit quaternion. |
Vector3f |
transformUnitPositiveZ(Vector3f dest)
Transform the vector
(0, 0, 1) by this unit quaternion. |
Vector4f |
transformUnitPositiveZ(Vector4f dest)
Transform the vector
(0, 0, 1) by this unit quaternion. |
float |
w() |
float |
x() |
float |
y() |
float |
z() |
float x()
float y()
float z()
float w()
Quaternionf normalize(Quaternionf dest)
dest.dest - will hold the resultQuaternionf add(float x, float y, float z, float w, Quaternionf dest)
(x, y, z, w) to this quaternion and store the result in dest.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 resultQuaternionf add(Quaternionfc q2, Quaternionf dest)
q2 to this quaternion and store the result in dest.q2 - the quaternion to add to thisdest - will hold the resultfloat angle()
Matrix3f get(Matrix3f dest)
this.dest - the matrix to write the rotation intoMatrix3f.set(Quaternionfc)Matrix3d get(Matrix3d dest)
this.dest - the matrix to write the rotation intoMatrix3d.set(Quaternionfc)Matrix4f get(Matrix4f dest)
this.dest - the matrix to write the rotation intoMatrix4f.set(Quaternionfc)Matrix4d get(Matrix4d dest)
this.dest - the matrix to write the rotation intoMatrix4d.set(Quaternionfc)Matrix4x3f get(Matrix4x3f dest)
this.dest - the matrix to write the rotation intoMatrix4x3f.set(Quaternionfc)Matrix4x3d get(Matrix4x3d dest)
this.dest - the matrix to write the rotation intoMatrix4x3d.set(Quaternionfc)AxisAngle4f get(AxisAngle4f dest)
AxisAngle4f to represent the rotation of
this quaternion.dest - the AxisAngle4f to setQuaterniond get(Quaterniond dest)
Quaterniond to the values of this.dest - the Quaterniond to setQuaterniond.set(Quaternionfc)Quaternionf get(Quaternionf dest)
Quaternionf to the values of this.dest - the Quaternionf to setByteBuffer getAsMatrix3f(ByteBuffer dest)
this quaternion in column-major order into the given ByteBuffer.
This is equivalent to calling: this.get(new Matrix3f()).get(dest)
dest - the destination bufferFloatBuffer getAsMatrix3f(FloatBuffer dest)
this quaternion in column-major order into the given FloatBuffer.
This is equivalent to calling: this.get(new Matrix3f()).get(dest)
dest - the destination bufferByteBuffer getAsMatrix4f(ByteBuffer dest)
this quaternion in column-major order into the given ByteBuffer.
This is equivalent to calling: this.get(new Matrix4f()).get(dest)
dest - the destination bufferFloatBuffer getAsMatrix4f(FloatBuffer dest)
this quaternion in column-major order into the given FloatBuffer.
This is equivalent to calling: this.get(new Matrix4f()).get(dest)
dest - the destination bufferByteBuffer getAsMatrix4x3f(ByteBuffer dest)
this quaternion in column-major order into the given ByteBuffer.
This is equivalent to calling: this.get(new Matrix4x3f()).get(dest)
dest - the destination bufferFloatBuffer getAsMatrix4x3f(FloatBuffer dest)
this quaternion in column-major order into the given FloatBuffer.
This is equivalent to calling: this.get(new Matrix4x3f()).get(dest)
dest - the destination bufferQuaternionf mul(Quaternionfc 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 resultQuaternionf mul(float qx, float qy, float qz, float qw, Quaternionf dest)
(qx, qy, qz, qw) 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.
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 resultQuaternionf premul(Quaternionfc 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 resultQuaternionf premul(float qx, float qy, float qz, float qw, Quaternionf dest)
(qx, qy, qz, qw) 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.
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 resultVector3f transform(Vector3f vec)
vec - the vector to transformVector3f transformPositiveX(Vector3f dest)
(1, 0, 0) by this quaternion.dest - will hold the resultVector4f transformPositiveX(Vector4f dest)
(1, 0, 0) by this quaternion.
Only the first three components of the given 4D vector are modified.
dest - will hold the resultVector3f transformUnitPositiveX(Vector3f dest)
(1, 0, 0) by this unit quaternion.
This method is only applicable when this is a unit quaternion.
Reference: https://de.mathworks.com/
dest - will hold the resultVector4f transformUnitPositiveX(Vector4f dest)
(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/
dest - will hold the resultVector3f transformPositiveY(Vector3f dest)
(0, 1, 0) by this quaternion.dest - will hold the resultVector4f transformPositiveY(Vector4f dest)
(0, 1, 0) by this quaternion.
Only the first three components of the given 4D vector are modified.
dest - will hold the resultVector3f transformUnitPositiveY(Vector3f dest)
(0, 1, 0) by this unit quaternion.
This method is only applicable when this is a unit quaternion.
Reference: https://de.mathworks.com/
dest - will hold the resultVector4f transformUnitPositiveY(Vector4f dest)
(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/
dest - will hold the resultVector3f transformPositiveZ(Vector3f dest)
(0, 0, 1) by this quaternion.dest - will hold the resultVector4f transformPositiveZ(Vector4f dest)
(0, 0, 1) by this quaternion.
Only the first three components of the given 4D vector are modified.
dest - will hold the resultVector3f transformUnitPositiveZ(Vector3f dest)
(0, 0, 1) by this unit quaternion.
This method is only applicable when this is a unit quaternion.
Reference: https://de.mathworks.com/
dest - will hold the resultVector4f transformUnitPositiveZ(Vector4f dest)
(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/
dest - will hold the resultVector4f transform(Vector4f vec)
Only the first three components of the given 4D vector are being used and modified.
vec - the vector to transformVector3f transform(Vector3fc 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 resultVector3f transform(float x, float y, float z, Vector3f dest)
(x, y, z) by this quaternion and store the result in dest.
This will apply the rotation described by this quaternion to the given vector.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 resultVector4f transform(Vector4fc 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 resultVector4f transform(float x, float y, float z, Vector4f dest)
(x, y, z) by this quaternion and store the result in dest.
This will apply the rotation described by this quaternion to the given vector.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 resultQuaternionf 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)Quaternionf div(Quaternionfc 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 Quaternionfc to divide this bydest - will hold the resultQuaternionf conjugate(Quaternionf dest)
dest.dest - will hold the resultQuaternionf 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 resultQuaternionf 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 resultQuaternionf 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 resultVector3f getEulerAnglesXYZ(Vector3f eulerAngles)
XYZ of this quaternion and store them in the
provided parameter eulerAngles.eulerAngles - will hold the euler angles in radiansfloat lengthSquared()
Quaternionf slerp(Quaternionfc target, float alpha, Quaternionf dest)
this unit quaternion and the specified
target unit quaternion using spherical 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 resultQuaternionf scale(float factor, Quaternionf dest)
factor, and store the result in dest.factor - the scaling factordest - will hold the resultQuaternionf 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 resultQuaternionf nlerp(Quaternionfc 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 resultQuaternionf nlerpIterative(Quaternionfc 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 resultQuaternionf lookAlong(Vector3fc dir, Vector3fc 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 resultlookAlong(float, float, float, float, float, float, Quaternionf)Quaternionf lookAlong(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 resultQuaternionf 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 resultQuaternionf rotateTo(Vector3fc fromDir, Vector3fc 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)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 resultQuaternionf 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 resultQuaternionf 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 resultQuaternionf 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 resultQuaternionf 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 resultQuaternionf 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 resultQuaternionf 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 resultQuaternionf rotateAxis(float angle, Vector3fc 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)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 resultVector3f positiveX(Vector3f dir)
+X before the rotation transformation represented by 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 +XVector3f normalizedPositiveX(Vector3f dir)
+X before the rotation transformation represented by 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 +XVector3f positiveY(Vector3f dir)
+Y before the rotation transformation represented by 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 +YVector3f normalizedPositiveY(Vector3f dir)
+Y before the rotation transformation represented by 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 +YVector3f positiveZ(Vector3f dir)
+Z before the rotation transformation represented by 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 +ZVector3f normalizedPositiveZ(Vector3f dir)
+Z before the rotation transformation represented by 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–2019 JOML. All rights reserved.