Orientation3DReadOnly
, Tuple4DReadOnly
QuaternionBasics
Quaternion
, Quaternion32
public interface QuaternionReadOnly extends Tuple4DReadOnly, Orientation3DReadOnly
When describing a 4D tuple, its 4 components are often gathered in two groups: the scalar part
s
and the vector part (x
, y
, z
).
Note on the difference between applying a 3D transform on a quaternion and a 4D vector:
s
remains unchanged. The vector part (x
, y
, z
) is scaled and rotated, and
translated by s
times the translation part of the transform. Note that for s = 0
,
a 4D vector behaves as a 3D vector, and for s = 1
it behaves as a 3D point.
Modifier and Type | Field | Description |
---|---|---|
static double |
EPS_UNITARY |
Default tolerance used to verify that this quaternion is a unit-quaternion.
|
static double |
GEOMETRICALLY_EQUALS_THRESHOLD |
Threshold used to trigger a more expensive comparison between two quaternions.
|
ORIENTATION_2D_EPSILON
Modifier and Type | Method | Description |
---|---|---|
default void |
addTransform(Tuple3DReadOnly tupleOriginal,
Tuple3DBasics tupleTransformed) |
Transforms the tuple
tupleOriginal by this orientation and adds the result to
tupleTransformed . |
default void |
checkIfIsZOnly(double epsilon) |
Deprecated.
|
default void |
checkIfUnitary() |
Asserts that this quaternion has a norm equal to 1+/-1.0E-7.
|
default void |
checkIfUnitary(double epsilon) |
Asserts that this quaternion has a norm equal to 1+/-
epsilon . |
default double |
distance(QuaternionReadOnly other) |
Computes and returns the distance from this quaternion to
other . |
default double |
distancePrecise(QuaternionReadOnly other) |
Computes and returns the distance from this quaternion to
other . |
default boolean |
geometricallyEquals(QuaternionReadOnly other,
double epsilon) |
Tests if
this and other represent the same orientation to an epsilon . |
default void |
get(AxisAngleBasics axisAngleToPack) |
Converts, if necessary, and packs this orientation into an axis-angle.
|
default void |
get(RotationMatrix rotationMatrixToPack) |
Converts, if necessary, and packs this orientation into a 3-by-3 rotation matrix.
|
default void |
get(QuaternionBasics quaternionToPack) |
Converts, if necessary, and packs this orientation in a quaternion.
|
default double |
getAngle() |
Calculates and returns the angle of the rotation this quaternion represents.
|
default void |
getEuler(Tuple3DBasics eulerAnglesToPack) |
Computes and packs the orientation described by this orientation as the Euler angles.
|
default double |
getPitch() |
Computes and returns the pitch angle from the yaw-pitch-roll representation of this orientation.
|
default double |
getRoll() |
Computes and returns the roll angle from the yaw-pitch-roll representation of this orientation.
|
default void |
getRotationVector(Vector3DBasics rotationVectorToPack) |
Converts and packs this orientation in a 3D rotation vector.
|
default double |
getYaw() |
Computes and returns the yaw angle from the yaw-pitch-roll representation of this orientation.
|
default void |
getYawPitchRoll(double[] yawPitchRollToPack) |
Converts and packs this orientation in a yaw-pitch-roll representation.
|
default void |
inverseTransform(Matrix3DReadOnly matrixOriginal,
Matrix3D matrixTransformed) |
Performs the inverse of the transform to the matrix
matrixOriginal by this orientation
and stores the result in matrixTransformed . |
default void |
inverseTransform(Tuple2DReadOnly tupleOriginal,
Tuple2DBasics tupleTransformed,
boolean checkIfOrientation2D) |
Performs the inverse of the transform to the tuple
tupleOriginal by this orientation and
stores the result in tupleTransformed . |
default void |
inverseTransform(Tuple3DReadOnly tupleOriginal,
Tuple3DBasics tupleTransformed) |
Performs the inverse of the transform to the tuple
tupleOriginal by this orientation and
stores the result in tupleTransformed . |
default void |
inverseTransform(Vector4DReadOnly vectorOriginal,
Vector4DBasics vectorTransformed) |
Performs the inverse of the transform to the vector part, i.e.
|
default boolean |
isOrientation2D(double epsilon) |
Tests if this orientation 3D actually represents a rotation strictly around the z-axis.
|
default boolean |
isUnitary(double epsilon) |
Tests if this quaternion has a norm equal to 1+/-
epsilon . |
default boolean |
isZOnly(double epsilon) |
Deprecated.
Use
isOrientation2D(double) instead |
default double |
norm() |
Efficiently compute the norm of this quaternion.
|
default void |
transform(Matrix3DReadOnly matrixOriginal,
Matrix3D matrixTransformed) |
Transforms the matrix
matrixOriginal by this orientation and stores the result in
matrixTransformed . |
default void |
transform(Tuple2DReadOnly tupleOriginal,
Tuple2DBasics tupleTransformed,
boolean checkIfOrientation2D) |
Transforms the tuple
tupleOriginal by this orientation and stores the result in
tupleTransformed . |
default void |
transform(Tuple3DReadOnly tupleOriginal,
Tuple3DBasics tupleTransformed) |
Transforms the tuple
tupleOriginal by this orientation and stores the result in
tupleTransformed . |
default void |
transform(Vector4DReadOnly vectorOriginal,
Vector4DBasics vectorTransformed) |
Transforms the vector part, i.e.
|
addTransform, checkIfOrientation2D, checkIfOrientation2D, inverseTransform, inverseTransform, inverseTransform, inverseTransform, inverseTransform, inverseTransform, inverseTransform, inverseTransform, inverseTransform, inverseTransform, inverseTransform, inverseTransform, isOrientation2D, toStringAsYawPitchRoll, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform
containsNaN, dot, epsilonEquals, equals, get, get, get, get, get, get, get, getElement, getElement32, getS, getS32, getX, getX32, getY, getY32, getZ, getZ32, normSquared
static final double GEOMETRICALLY_EQUALS_THRESHOLD
static final double EPS_UNITARY
default boolean isUnitary(double epsilon)
epsilon
.epsilon
- the tolerance to use.true
if this quaternion is a proper unit-quaternion, false
otherwise.@Deprecated default boolean isZOnly(double epsilon)
isOrientation2D(double)
insteadThis is commonly used to test if the quaternion can be used to transform 2D geometry object.
epsilon
- the tolerance to use.true
if this quaternion represents a rotation around the z-axis, false
otherwise.default boolean isOrientation2D(double epsilon)
This is commonly used to test if this orientation can be used to transform 2D geometry object.
The implementation of this test depends on the type of representation used for this orientation.
A quaternion is an orientation 2D if:
epsilon
.
epsilon
.
isOrientation2D
in interface Orientation3DReadOnly
epsilon
- the tolerance to use.true
if this orientation represents a 2D orientation in the XY-plane,
false
otherwise.default void checkIfUnitary()
epsilon
- the tolerance to use.java.lang.RuntimeException
- if this quaternion is not a proper unit-quaternion.default void checkIfUnitary(double epsilon)
epsilon
.epsilon
- the tolerance to use.java.lang.RuntimeException
- if this quaternion is not a proper unit-quaternion.@Deprecated default void checkIfIsZOnly(double epsilon)
This is commonly used to test if the quaternion can be used to transform 2D geometry object.
epsilon
- the tolerance to use.NotAMatrix2DException
- if this quaternion does not represent a rotation around the z-axis.default double norm()
norm
in interface Tuple4DReadOnly
default double distance(QuaternionReadOnly other)
other
.other
- the other quaternion to measure the distance. Not modified.default double distancePrecise(QuaternionReadOnly other)
other
.
This method is equivalent to distance(QuaternionReadOnly)
but is more accurate when
computing the distance between two quaternions that are very close. Note that it is also more
expensive.
other
- the other quaternion to measure the distance. Not modified.default double getAngle()
default void get(RotationMatrix rotationMatrixToPack)
get
in interface Orientation3DReadOnly
rotationMatrixToPack
- the rotation matrix into which this orientation is to be stored.
Modified.default void get(AxisAngleBasics axisAngleToPack)
get
in interface Orientation3DReadOnly
axisAngleToPack
- the axis-angle into which this orientation is to be stored. Modified.default void get(QuaternionBasics quaternionToPack)
get
in interface Orientation3DReadOnly
quaternionToPack
- the quaternion into which this orientation is to be stored. Modified.default void getRotationVector(Vector3DBasics rotationVectorToPack)
WARNING: a rotation vector is different from a yaw-pitch-roll or Euler angles representation. A rotation vector is equivalent to the axis of an axis-angle that is multiplied by the angle of the same axis-angle.
getRotationVector
in interface Orientation3DReadOnly
rotationVectorToPack
- the rotation vector in which this orientation is to be stored.
Modified.default void getYawPitchRoll(double[] yawPitchRollToPack)
WARNING: the Euler angles or yaw-pitch-roll representation is sensitive to gimbal lock and is sometimes undefined.
The yaw-pitch-roll representation describes a 3D orientation as a succession of three rotations around three axes:
As an example, a rotation matrix can be computed from a yaw-pitch-roll representation as follows:
/ cos(yaw) -sin(yaw) 0 \ / cos(pitch) 0 sin(pitch) \ / 1 0 0 \ R = | sin(yaw) cos(yaw) 0 | * | 0 1 0 | * | 0 cos(roll) -sin(roll) | \ 0 0 1 / \ -sin(pitch) 0 cos(pitch) / \ 0 sin(roll) cos(roll) /
getYawPitchRoll
in interface Orientation3DReadOnly
yawPitchRollToPack
- the array in which the yaw-pitch-roll angles are stored. Modified.default void getEuler(Tuple3DBasics eulerAnglesToPack)
WARNING: the Euler angles or yaw-pitch-roll representation is sensitive to gimbal lock and is sometimes undefined.
getEuler
in interface Orientation3DReadOnly
eulerAnglesToPack
- the tuple in which the Euler angles are stored. Modified.default double getYaw()
WARNING: the Euler angles or yaw-pitch-roll representation is sensitive to gimbal lock and is sometimes undefined.
getYaw
in interface Orientation3DReadOnly
default double getPitch()
WARNING: the Euler angles or yaw-pitch-roll representation is sensitive to gimbal lock and is sometimes undefined.
getPitch
in interface Orientation3DReadOnly
default double getRoll()
WARNING: the Euler angles or yaw-pitch-roll representation is sensitive to gimbal lock and is sometimes undefined.
getRoll
in interface Orientation3DReadOnly
default void transform(Tuple3DReadOnly tupleOriginal, Tuple3DBasics tupleTransformed)
tupleOriginal
by this orientation and stores the result in
tupleTransformed
.
If the given tuple is expressed in the local frame described by this orientation, then the tuple is transformed such that it is, after this method is called, expressed in the base frame in which this orientation is expressed.
transform
in interface Orientation3DReadOnly
tupleOriginal
- the original value of the tuple to be transformed. Not modified.tupleTransformed
- the result of the original tuple after transformation. Modified.default void addTransform(Tuple3DReadOnly tupleOriginal, Tuple3DBasics tupleTransformed)
tupleOriginal
by this orientation and adds the result to
tupleTransformed
.
If the given tuple is expressed in the local frame described by this orientation, then the tuple is transformed such that it is, after this method is called, expressed in the base frame in which this orientation is expressed.
addTransform
in interface Orientation3DReadOnly
tupleOriginal
- the original value of the tuple to be transformed. Not modified.tupleTransformed
- the result of the original tuple after transformation. Modified.default void transform(Tuple2DReadOnly tupleOriginal, Tuple2DBasics tupleTransformed, boolean checkIfOrientation2D)
tupleOriginal
by this orientation and stores the result in
tupleTransformed
.
If the given tuple is expressed in the local frame described by this orientation, then the tuple is transformed such that it is, after this method is called, expressed in the base frame in which this orientation is expressed.
transform
in interface Orientation3DReadOnly
tupleOriginal
- the original value of the tuple to be transformed. Not modified.tupleTransformed
- the result of the original tuple after transformation. Modified.checkIfOrientation2D
- whether this method should assert that this orientation represents a
transformation in the XY plane.default void transform(Matrix3DReadOnly matrixOriginal, Matrix3D matrixTransformed)
matrixOriginal
by this orientation and stores the result in
matrixTransformed
.
If the given matrix is expressed in the local frame described by this orientation, then the matrix is transformed such that it is, after this method is called, expressed in the base frame in which this orientation is expressed.
transform
in interface Orientation3DReadOnly
matrixOriginal
- the original value of the matrix to be transformed. Not modified.matrixTransformed
- the result of the original matrix after transformation. Modified.default void transform(Vector4DReadOnly vectorOriginal, Vector4DBasics vectorTransformed)
x
, y
, and z
components, of the given
vectorOriginal
and stores the result in vectorTransformed
.
The scalar component s
remains unaffected by this operation and is simply copied over.
If the given vector part is expressed in the local frame described by this orientation, then the vector part is transformed such that it is, after this method is called, expressed in the base frame in which this orientation is expressed.
transform
in interface Orientation3DReadOnly
vectorOriginal
- the original value of the vector to be transformed. Not modified.vectorTransformed
- the result of the original vector after transformation. Modified.default void inverseTransform(Tuple3DReadOnly tupleOriginal, Tuple3DBasics tupleTransformed)
tupleOriginal
by this orientation and
stores the result in tupleTransformed
.
If the given tuple is expressed in the base frame in which this orientation is expressed, then the tuple is transformed such that it is, after this method is called, expressed in the local frame described by this orientation.
inverseTransform
in interface Orientation3DReadOnly
tupleOriginal
- the original value of the tuple to be transformed. Not modified.tupleTransformed
- the result of the original tuple after transformation. Modified.default void inverseTransform(Tuple2DReadOnly tupleOriginal, Tuple2DBasics tupleTransformed, boolean checkIfOrientation2D)
tupleOriginal
by this orientation and
stores the result in tupleTransformed
.
If the given tuple is expressed in the base frame in which this orientation is expressed, then the tuple is transformed such that it is, after this method is called, expressed in the local frame described by this orientation.
inverseTransform
in interface Orientation3DReadOnly
tupleOriginal
- the original value of the tuple to be transformed. Not modified.tupleTransformed
- the result of the original tuple after transformation. Modified.checkIfOrientation2D
- whether this method should assert that this orientation represents a
transformation in the XY plane.default void inverseTransform(Vector4DReadOnly vectorOriginal, Vector4DBasics vectorTransformed)
x
, y
, and
z
components, of the given vectorOriginal
and stores the result in
vectorTransformed
.
The scalar component s
remains unaffected by this operation and is simply copied over.
If the given vector part is expressed in the local frame described by this orientation, then the vector part is transformed such that it is, after this method is called, expressed in the base frame in which this orientation is expressed.
inverseTransform
in interface Orientation3DReadOnly
vectorOriginal
- the original value of the vector to be transformed. Not modified.vectorTransformed
- the result of the original vector after transformation. Modified.default void inverseTransform(Matrix3DReadOnly matrixOriginal, Matrix3D matrixTransformed)
matrixOriginal
by this orientation
and stores the result in matrixTransformed
.
If the given matrix is expressed in the base frame in which this orientation is expressed, then the matrix is transformed such that it is, after this method is called, expressed in the local frame described by this orientation.
inverseTransform
in interface Orientation3DReadOnly
matrixOriginal
- the original value of the matrix to be transformed. Not modified.matrixTransformed
- the result of the original matrix after transformation. Modified.default boolean geometricallyEquals(QuaternionReadOnly other, double epsilon)
this
and other
represent the same orientation to an epsilon
.
Two quaternions are considered geometrically equal if the magnitude of their difference is less
than or equal to epsilon
.
Note that two quaternions of opposite sign are considered equal, such that the two quaternions
q1 = (x, y, z, s)
and q2 = (-x, -y, -z, -s)
are considered geometrically equal.
Note that this.geometricallyEquals(other, epsilon) == true
does not necessarily imply
this.epsilonEquals(other, epsilon)
and vice versa.
other
- the other quaternion to compare against this. Not modified.epsilon
- the maximum angle of the difference quaternion can be for the two quaternions to
be considered equal.true
if the two quaternions represent the same geometry, false
otherwise.