|
JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java (public API).
|
Quaternion implementation supporting Gimbal-Lock free rotations. More...
Public Member Functions | |
| Quaternion () | |
| Quaternion (final Quaternion q) | |
| Quaternion (final float x, final float y, final float z, final float w) | |
| Quaternion | copy () |
| final float | magnitudeSquared () |
See magnitude() for special handling of epsilon, which is not applied here. More... | |
| final float | magnitude () |
| Return the magnitude of this quaternion, i.e. More... | |
| final float | w () |
| final void | setW (final float w) |
| final float | x () |
| final void | setX (final float x) |
| final float | y () |
| final void | setY (final float y) |
| final float | z () |
| final void | setZ (final float z) |
| final float | dot (final float x, final float y, final float z, final float w) |
| Returns the dot product of this quaternion with the given x,y,z and w components. More... | |
| final float | dot (final Quaternion quat) |
| Returns the dot product of this quaternion with the given quaternion. More... | |
| final boolean | isIdentity () |
Returns true if this quaternion has identity. More... | |
| final Quaternion | setIdentity () |
| final Quaternion | normalize () |
| Normalize a quaternion required if to be used as a rotational quaternion. More... | |
| Quaternion | conjugate () |
Conjugates this quaternion [-x, -y, -z, w]. More... | |
| final Quaternion | invert () |
| Invert the quaternion If rotational, will produce a the inverse rotation. More... | |
| final Quaternion | set (final Quaternion src) |
| Set all values of this quaternion using the given src. More... | |
| final Quaternion | set (final float x, final float y, final float z, final float w) |
| Set all values of this quaternion using the given components. More... | |
| final Quaternion | add (final Quaternion q) |
| Add a quaternion. More... | |
| final Quaternion | subtract (final Quaternion q) |
| Subtract a quaternion. More... | |
| final Quaternion | mult (final Quaternion q) |
| Multiply this quaternion by the param quaternion. More... | |
| final Quaternion | scale (final float n) |
| Scale this quaternion by a constant. More... | |
| Quaternion | rotateByAngleNormalAxis (final float angle, final float axisX, final float axisY, final float axisZ) |
| Rotate this quaternion by the given angle and axis. More... | |
| Quaternion | rotateByAngleNormalAxis (final float angle, final Vec3f axis) |
| Rotate this quaternion by the given angle and axis. More... | |
| Quaternion | rotateByAngleX (final float angle) |
| Rotate this quaternion around X axis with the given angle in radians. More... | |
| Quaternion | rotateByAngleY (final float angle) |
| Rotate this quaternion around Y axis with the given angle in radians. More... | |
| Quaternion | rotateByAngleZ (final float angle) |
| Rotate this quaternion around Z axis with the given angle in radians. More... | |
| final Quaternion | rotateByEuler (final Vec3f angradXYZ) |
Rotates this quaternion from the given Euler rotation array angradXYZ in radians. More... | |
| final Quaternion | rotateByEuler (final float bankX, final float headingY, final float attitudeZ) |
| Rotates this quaternion from the given Euler rotation angles in radians. More... | |
| final Vec3f | rotateVector (final Vec3f vecIn, final Vec3f vecOut) |
| final Quaternion | setSlerp (final Quaternion a, final Quaternion b, final float changeAmnt) |
| Set this quaternion to a spherical linear interpolation between the given start and end quaternions by the given change amount. More... | |
| Quaternion | setLookAt (final Vec3f directionIn, final Vec3f upIn, final Vec3f xAxisOut, final Vec3f yAxisOut, final Vec3f zAxisOut) |
| Set this quaternion to equal the rotation required to point the z-axis at direction and the y-axis to up. More... | |
| final Quaternion | setFromVectors (final Vec3f v1, final Vec3f v2, final Vec3f tmpPivotVec, final Vec3f tmpNormalVec) |
| Initialize this quaternion from two vectors. More... | |
| final Quaternion | setFromNormalVectors (final Vec3f v1, final Vec3f v2, final Vec3f tmpPivotVec) |
| Initialize this quaternion from two normalized vectors. More... | |
| final Quaternion | setFromAngleAxis (final float angle, final Vec3f vector, final Vec3f tmpV3f) |
| final Quaternion | setFromAngleNormalAxis (final float angle, final Vec3f vector) |
| final float | toAngleAxis (final Vec3f axis) |
| Transform the rotational quaternion to axis based rotation angles. More... | |
| final Quaternion | setFromEuler (final Vec3f angradXYZ) |
Initializes this quaternion from the given Euler rotation array angradXYZ in radians. More... | |
| final Quaternion | setFromEuler (final float bankX, final float headingY, final float attitudeZ) |
| Initializes this quaternion from the given Euler rotation angles in radians. More... | |
| Vec3f | toEuler (final Vec3f result) |
| Transform this quaternion to Euler rotation angles in radians (pitchX, yawY and rollZ). More... | |
| Quaternion | setFromMat (final float m00, final float m01, final float m02, final float m10, final float m11, final float m12, final float m20, final float m21, final float m22) |
| Compute the quaternion from a 3x3 column rotation matrix. More... | |
| Quaternion | setFromMat (final Matrix4f m) |
Compute the quaternion from a 3x3 column rotation matrix from Matrix4f instance. More... | |
| final float[] | toMatrix (final float[] matrix) |
| Transform this quaternion to a normalized 4x4 column matrix representing the rotation. More... | |
| final Matrix4f | toMatrix (final Matrix4f matrix) |
| Transform this quaternion to a normalized 4x4 column matrix representing the rotation. More... | |
| final Quaternion | setFromAxes (final Vec3f xAxis, final Vec3f yAxis, final Vec3f zAxis) |
| Initializes this quaternion to represent a rotation formed by the given three orthogonal axes. More... | |
| void | toAxes (final Vec3f xAxis, final Vec3f yAxis, final Vec3f zAxis, final Matrix4f tmpMat4) |
| Extracts this quaternion's orthogonal rotation axes. More... | |
| final boolean | isRotationMatrix3f (final float[] m) |
| Check if the the 3x3 matrix (param) is in fact an affine rotational matrix. More... | |
| boolean | equals (final Object o) |
| final int | hashCode () |
| String | toString () |
Static Public Attributes | |
| static final float | ALLOWED_DEVIANCE = 1.0E-6f |
| Quaternion Epsilon, used with equals method to determine if two Quaternions are close enough to be considered equal. More... | |
Quaternion implementation supporting Gimbal-Lock free rotations.
All matrix operation provided are in column-major order, as specified in the OpenGL fixed function pipeline, i.e. compatibility profile. See FloatUtil.
See Matrix-FAQ
See euclideanspace.com-Quaternion
Definition at line 45 of file Quaternion.java.
| com.jogamp.math.Quaternion.Quaternion | ( | ) |
| com.jogamp.math.Quaternion.Quaternion | ( | final Quaternion | q | ) |
Definition at line 60 of file Quaternion.java.
| com.jogamp.math.Quaternion.Quaternion | ( | final float | x, |
| final float | y, | ||
| final float | z, | ||
| final float | w | ||
| ) |
Definition at line 64 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.add | ( | final Quaternion | q | ) |
Add a quaternion.
| q | quaternion |
Definition at line 265 of file Quaternion.java.
| Quaternion com.jogamp.math.Quaternion.conjugate | ( | ) |
Conjugates this quaternion [-x, -y, -z, w].
Definition at line 202 of file Quaternion.java.
| Quaternion com.jogamp.math.Quaternion.copy | ( | ) |
Definition at line 68 of file Quaternion.java.
| final float com.jogamp.math.Quaternion.dot | ( | final float | x, |
| final float | y, | ||
| final float | z, | ||
| final float | w | ||
| ) |
Returns the dot product of this quaternion with the given x,y,z and w components.
Definition at line 139 of file Quaternion.java.
| final float com.jogamp.math.Quaternion.dot | ( | final Quaternion | quat | ) |
Returns the dot product of this quaternion with the given quaternion.
Definition at line 146 of file Quaternion.java.
| boolean com.jogamp.math.Quaternion.equals | ( | final Object | o | ) |
| o | the object to compare for equality |
Definition at line 1168 of file Quaternion.java.
| final int com.jogamp.math.Quaternion.hashCode | ( | ) |
Definition at line 1182 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.invert | ( | ) |
Invert the quaternion If rotational, will produce a the inverse rotation.
Implementation Details:
conjugates if magnitudeSquared() is is equals 1f using epsilon Definition at line 220 of file Quaternion.java.
| final boolean com.jogamp.math.Quaternion.isIdentity | ( | ) |
Returns true if this quaternion has identity.
Implementation uses epsilon to compare W against 1f and X, Y and Z against zero.
Definition at line 159 of file Quaternion.java.
| final boolean com.jogamp.math.Quaternion.isRotationMatrix3f | ( | final float[] | m | ) |
Check if the the 3x3 matrix (param) is in fact an affine rotational matrix.
| m | 3x3 column matrix |
Definition at line 1136 of file Quaternion.java.
| final float com.jogamp.math.Quaternion.magnitude | ( | ) |
Return the magnitude of this quaternion, i.e.
sqrt(magnitudeSquared())
A magnitude of zero shall equal identity, as performed by normalize().
Implementation Details:
magnitudeSquared() is is zero using epsilon magnitudeSquared() is equals 1f using epsilon Definition at line 93 of file Quaternion.java.
| final float com.jogamp.math.Quaternion.magnitudeSquared | ( | ) |
See magnitude() for special handling of epsilon, which is not applied here.
Definition at line 75 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.mult | ( | final Quaternion | q | ) |
Multiply this quaternion by the param quaternion.
| q | a quaternion to multiply with |
Definition at line 296 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.normalize | ( | ) |
Normalize a quaternion required if to be used as a rotational quaternion.
Implementation Details:
setIdentity() if magnitude() is is zero using epsilon Definition at line 183 of file Quaternion.java.
| Quaternion com.jogamp.math.Quaternion.rotateByAngleNormalAxis | ( | final float | angle, |
| final float | axisX, | ||
| final float | axisY, | ||
| final float | axisZ | ||
| ) |
Rotate this quaternion by the given angle and axis.
The axis must be a normalized vector.
A rotational quaternion is made from the given angle and axis.
| angle | in radians |
| axisX | x-coord of rotation axis |
| axisY | y-coord of rotation axis |
| axisZ | z-coord of rotation axis |
Definition at line 333 of file Quaternion.java.
| Quaternion com.jogamp.math.Quaternion.rotateByAngleNormalAxis | ( | final float | angle, |
| final Vec3f | axis | ||
| ) |
Rotate this quaternion by the given angle and axis.
The axis must be a normalized vector.
A rotational quaternion is made from the given angle and axis.
| angle | in radians |
| axis | Vec3f coord of rotation axis |
Definition at line 363 of file Quaternion.java.
| Quaternion com.jogamp.math.Quaternion.rotateByAngleX | ( | final float | angle | ) |
Rotate this quaternion around X axis with the given angle in radians.
| angle | in radians |
Definition at line 373 of file Quaternion.java.
| Quaternion com.jogamp.math.Quaternion.rotateByAngleY | ( | final float | angle | ) |
Rotate this quaternion around Y axis with the given angle in radians.
| angle | in radians |
Definition at line 389 of file Quaternion.java.
| Quaternion com.jogamp.math.Quaternion.rotateByAngleZ | ( | final float | angle | ) |
Rotate this quaternion around Z axis with the given angle in radians.
| angle | in radians |
Definition at line 405 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.rotateByEuler | ( | final float | bankX, |
| final float | headingY, | ||
| final float | attitudeZ | ||
| ) |
Rotates this quaternion from the given Euler rotation angles in radians.
The rotations are applied in the given order and using chained rotation per axis:
rotateByAngleY(float) rotateByAngleZ(float) rotateByAngleX(float) Implementation Details:
is zero using epsilon normalize()ed | bankX | the Euler pitch angle in radians. (rotation about the X axis) |
| headingY | the Euler yaw angle in radians. (rotation about the Y axis) |
| attitudeZ | the Euler roll angle in radians. (rotation about the Z axis) |
Definition at line 460 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.rotateByEuler | ( | final Vec3f | angradXYZ | ) |
Rotates this quaternion from the given Euler rotation array angradXYZ in radians.
The angradXYZ array is laid out in natural order:
For details see rotateByEuler(float, float, float).
| angradXYZ | euler angle array in radians |
Definition at line 430 of file Quaternion.java.
Definition at line 478 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.scale | ( | final float | n | ) |
Scale this quaternion by a constant.
| n | a float constant |
Definition at line 310 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.set | ( | final float | x, |
| final float | y, | ||
| final float | z, | ||
| final float | w | ||
| ) |
Set all values of this quaternion using the given components.
Definition at line 250 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.set | ( | final Quaternion | src | ) |
Set all values of this quaternion using the given src.
Definition at line 238 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.setFromAngleAxis | ( | final float | angle, |
| final Vec3f | vector, | ||
| final Vec3f | tmpV3f | ||
| ) |
Definition at line 768 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.setFromAngleNormalAxis | ( | final float | angle, |
| final Vec3f | vector | ||
| ) |
Definition at line 788 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.setFromAxes | ( | final Vec3f | xAxis, |
| final Vec3f | yAxis, | ||
| final Vec3f | zAxis | ||
| ) |
Initializes this quaternion to represent a rotation formed by the given three orthogonal axes.
No validation whether the axes are orthogonal is performed.
| xAxis | vector representing the orthogonal x-axis of the coordinate system. |
| yAxis | vector representing the orthogonal y-axis of the coordinate system. |
| zAxis | vector representing the orthogonal z-axis of the coordinate system. |
Definition at line 1107 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.setFromEuler | ( | final float | bankX, |
| final float | headingY, | ||
| final float | attitudeZ | ||
| ) |
Initializes this quaternion from the given Euler rotation angles in radians.
The rotations are applied in the given order:
Implementation Details:
setIdentity() if all angles are is zero using epsilon normalize()ed | bankX | the Euler pitch angle in radians. (rotation about the X axis) |
| headingY | the Euler yaw angle in radians. (rotation about the Y axis) |
| attitudeZ | the Euler roll angle in radians. (rotation about the Z axis) |
Definition at line 871 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.setFromEuler | ( | final Vec3f | angradXYZ | ) |
Initializes this quaternion from the given Euler rotation array angradXYZ in radians.
The angradXYZ vector is laid out in natural order:
For details see setFromEuler(float, float, float).
| angradXYZ | euler angle vector in radians holding x-bank, y-heading and z-attitude |
Definition at line 840 of file Quaternion.java.
| Quaternion com.jogamp.math.Quaternion.setFromMat | ( | final float | m00, |
| final float | m01, | ||
| final float | m02, | ||
| final float | m10, | ||
| final float | m11, | ||
| final float | m12, | ||
| final float | m20, | ||
| final float | m21, | ||
| final float | m22 | ||
| ) |
Compute the quaternion from a 3x3 column rotation matrix.
See Graphics Gems Code,
MatrixTrace.
Buggy Matrix-FAQ Q55
Definition at line 952 of file Quaternion.java.
| Quaternion com.jogamp.math.Quaternion.setFromMat | ( | final Matrix4f | m | ) |
Compute the quaternion from a 3x3 column rotation matrix from Matrix4f instance.
See Graphics Gems Code,
MatrixTrace.
Buggy Matrix-FAQ Q55
Definition at line 1008 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.setFromNormalVectors | ( | final Vec3f | v1, |
| final Vec3f | v2, | ||
| final Vec3f | tmpPivotVec | ||
| ) |
Initialize this quaternion from two normalized vectors.
q = (s,v) = (v1•v2 , v1 × v2),
angle = angle(v1, v2) = v1•v2
axis = v1 x v2
<p<blockquote>
Implementation Details:
setIdentity() if square vector-length is is zero using epsilon | v1 | normalized |
| v2 | normalized |
| tmpPivotVec | temp storage for cross product |
Definition at line 715 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.setFromVectors | ( | final Vec3f | v1, |
| final Vec3f | v2, | ||
| final Vec3f | tmpPivotVec, | ||
| final Vec3f | tmpNormalVec | ||
| ) |
Initialize this quaternion from two vectors.
q = (s,v) = (v1•v2 , v1 × v2),
angle = angle(v1, v2) = v1•v2
axis = normal(v1 x v2)
<p<blockquote>
Implementation Details:
setIdentity() if square vector-length is is zero using epsilon | v1 | not normalized |
| v2 | not normalized |
| tmpPivotVec | temp storage for cross product |
| tmpNormalVec | temp storage to normalize vector |
Definition at line 660 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.setIdentity | ( | ) |
| Quaternion com.jogamp.math.Quaternion.setLookAt | ( | final Vec3f | directionIn, |
| final Vec3f | upIn, | ||
| final Vec3f | xAxisOut, | ||
| final Vec3f | yAxisOut, | ||
| final Vec3f | zAxisOut | ||
| ) |
Set this quaternion to equal the rotation required to point the z-axis at direction and the y-axis to up.
Implementation generates a 3x3 matrix and is equal with ProjectFloat's lookAt(..).
Implementation Details:
normalize()ed | directionIn | where to look at |
| upIn | a vector indicating the local up direction. |
| xAxisOut | vector storing the orthogonal x-axis of the coordinate system. |
| yAxisOut | vector storing the orthogonal y-axis of the coordinate system. |
| zAxisOut | vector storing the orthogonal z-axis of the coordinate system. |
Definition at line 609 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.setSlerp | ( | final Quaternion | a, |
| final Quaternion | b, | ||
| final float | changeAmnt | ||
| ) |
Set this quaternion to a spherical linear interpolation between the given start and end quaternions by the given change amount.
Note: Method does not normalize this quaternion!
| a | start quaternion |
| b | end quaternion |
| changeAmnt | float between 0 and 1 representing interpolation. |
Definition at line 525 of file Quaternion.java.
| final void com.jogamp.math.Quaternion.setW | ( | final float | w | ) |
Definition at line 108 of file Quaternion.java.
| final void com.jogamp.math.Quaternion.setX | ( | final float | x | ) |
Definition at line 116 of file Quaternion.java.
| final void com.jogamp.math.Quaternion.setY | ( | final float | y | ) |
Definition at line 124 of file Quaternion.java.
| final void com.jogamp.math.Quaternion.setZ | ( | final float | z | ) |
Definition at line 132 of file Quaternion.java.
| final Quaternion com.jogamp.math.Quaternion.subtract | ( | final Quaternion | q | ) |
Subtract a quaternion.
| q | quaternion |
Definition at line 280 of file Quaternion.java.
| final float com.jogamp.math.Quaternion.toAngleAxis | ( | final Vec3f | axis | ) |
Transform the rotational quaternion to axis based rotation angles.
| axis | storage for computed axis |
Definition at line 809 of file Quaternion.java.
| void com.jogamp.math.Quaternion.toAxes | ( | final Vec3f | xAxis, |
| final Vec3f | yAxis, | ||
| final Vec3f | zAxis, | ||
| final Matrix4f | tmpMat4 | ||
| ) |
Extracts this quaternion's orthogonal rotation axes.
| xAxis | vector representing the orthogonal x-axis of the coordinate system. |
| yAxis | vector representing the orthogonal y-axis of the coordinate system. |
| zAxis | vector representing the orthogonal z-axis of the coordinate system. |
| tmpMat4 | temporary float[4] matrix, used to transform this quaternion to a matrix. |
Definition at line 1121 of file Quaternion.java.
Transform this quaternion to Euler rotation angles in radians (pitchX, yawY and rollZ).
The result array is laid out in natural order:
| result | euler angle result vector for radians x-bank, y-heading and z-attitude |
result filled with x-bank, y-heading and z-attitude Definition at line 915 of file Quaternion.java.
| final float[] com.jogamp.math.Quaternion.toMatrix | ( | final float[] | matrix | ) |
Transform this quaternion to a normalized 4x4 column matrix representing the rotation.
Implementation Details:
magnitudeSquared() is is zero using epsilon | matrix | float[16] store for the resulting normalized column matrix 4x4 |
Definition at line 1027 of file Quaternion.java.
Transform this quaternion to a normalized 4x4 column matrix representing the rotation.
Implementation Details:
magnitudeSquared() is is zero using epsilon | matrix | store for the resulting normalized column matrix 4x4 |
Definition at line 1092 of file Quaternion.java.
| String com.jogamp.math.Quaternion.toString | ( | ) |
Definition at line 1187 of file Quaternion.java.
| final float com.jogamp.math.Quaternion.w | ( | ) |
Definition at line 104 of file Quaternion.java.
| final float com.jogamp.math.Quaternion.x | ( | ) |
Definition at line 112 of file Quaternion.java.
| final float com.jogamp.math.Quaternion.y | ( | ) |
Definition at line 120 of file Quaternion.java.
| final float com.jogamp.math.Quaternion.z | ( | ) |
Definition at line 128 of file Quaternion.java.
|
static |
Quaternion Epsilon, used with equals method to determine if two Quaternions are close enough to be considered equal.
Using {@value}, which is ~10 times FloatUtil#EPSILON.
Definition at line 54 of file Quaternion.java.