Clearable
, EpsilonComparable<Quaternion>
, GeometricallyComparable<Quaternion>
, GeometryObject<Quaternion>
, Settable<Quaternion>
, Transformable
, Orientation3DBasics
, Orientation3DReadOnly
, QuaternionBasics
, QuaternionReadOnly
, Tuple4DBasics
, Tuple4DReadOnly
public class Quaternion extends java.lang.Object implements QuaternionBasics, GeometryObject<Quaternion>
This version of quaternion uses double precision fields to save the value of each component. It is meant for garbage free usage.
ORIENTATION_2D_EPSILON
EPS_POW
EPS_UNITARY, GEOMETRICALLY_EQUALS_THRESHOLD
Constructor | Description |
---|---|
Quaternion() |
Creates a new quaternion and initializes it to the neutral quaternion which represents a
'zero' rotation.
|
Quaternion(double[] quaternionArray) |
Creates a new quaternion and initializes its component
x , y , z ,
s in order from the given array. |
Quaternion(double yaw,
double pitch,
double roll) |
Creates and new quaternion and initializes such that it represents the same orientation as the
given yaw-pitch-roll
yaw , pitch , and roll . |
Quaternion(double x,
double y,
double z,
double s) |
Creates a new quaternion and initializes it with the given components.
|
Quaternion(org.ejml.data.DenseMatrix64F matrix) |
Creates a new quaternion and initializes its component
x , y , z ,
s in order from the given matrix. |
Quaternion(Orientation3DReadOnly orientation) |
Creates a new quaternion and initializes such that it represents the same orientation as the
given one.
|
Quaternion(Vector3DReadOnly rotationVector) |
Creates a new quaternion and initializes such that it represents the same orientation as the
given
rotationVector . |
Quaternion(QuaternionReadOnly other) |
Creates a new quaternion and initializes it to
other . |
Quaternion(Tuple4DReadOnly other) |
Creates a new quaternion and initializes it to
other . |
Modifier and Type | Method | Description |
---|---|---|
boolean |
epsilonEquals(Quaternion other,
double epsilon) |
Tests on a per component basis if this quaternion is equal to the given
other to an
epsilon . |
boolean |
equals(java.lang.Object object) |
Tests if the given
object 's class is the same as this, in which case the method
returns Tuple4DReadOnly.equals(Tuple4DReadOnly) , it returns false otherwise. |
boolean |
geometricallyEquals(Quaternion other,
double epsilon) |
Tests if
this and other represent the same orientation to an epsilon . |
double |
getS() |
Returns the s-component of this tuple.
|
double |
getX() |
Returns the x-component of this tuple.
|
double |
getY() |
Returns the y-component of this tuple.
|
double |
getZ() |
Returns the z-component of this tuple.
|
int |
hashCode() |
Calculates and returns a hash code value from the value of each component of this quaternion.
|
void |
set(Quaternion other) |
Sets this quaternion to
other . |
void |
setUnsafe(double qx,
double qy,
double qz,
double qs) |
Sets the four components of this quaternion without normalizing.
|
java.lang.String |
toString() |
Provides a
String representation of this quaternion as follows: (x, y, z, s). |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
appendInvertBoth, appendInvertThis, prependInvertBoth, prependInvertThis, setAndInvert, setAndNormalize, setEuler, setEuler, setRotationVector, setYawPitchRoll
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
absolute, append, appendInvertOther, appendPitchRotation, appendRollRotation, appendYawRotation, applyInverseTransform, applyTransform, conjugate, difference, interpolate, interpolate, inverse, invert, multiply, multiply, multiplyConjugateBoth, multiplyConjugateOther, multiplyConjugateThis, negate, normalize, normalizeAndLimitToPi, pow, preMultiply, preMultiplyConjugateBoth, preMultiplyConjugateOther, preMultiplyConjugateThis, prepend, prependInvertOther, prependPitchRotation, prependRollRotation, prependYawRotation, set, set, set, setAndConjugate, setAndInverse, setAndNegate, setAndNormalize, setAndNormalize, setAxisAngle, setQuaternion, setRotationMatrix, setRotationVector, setToPitchQuaternion, setToRollQuaternion, setToYawQuaternion, setToZero, setYawPitchRoll
addTransform, checkIfIsZOnly, checkIfUnitary, checkIfUnitary, distance, distancePrecise, geometricallyEquals, get, get, get, getAngle, getEuler, getPitch, getRoll, getRotationVector, getYaw, getYawPitchRoll, inverseTransform, inverseTransform, inverseTransform, inverseTransform, isOrientation2D, isUnitary, isZOnly, norm, transform, transform, transform, transform
containsNaN, set, set, set, set, set, set, set, set, setAndAbsolute, setAndNegate, setToNaN
dot, epsilonEquals, equals, get, get, get, get, get, get, get, getElement, getElement32, getS32, getX32, getY32, getZ32, normSquared
public Quaternion()
public Quaternion(double x, double y, double z, double s)
The quaternion is immediately normalized.
x
- the x-component.y
- the y-component.z
- the z-component.s
- the s-component.public Quaternion(double[] quaternionArray)
x
, y
, z
,
s
in order from the given array.
The quaternion is immediately normalized.
quaternionArray
- the array containing this quaternion's components. Not modified.public Quaternion(org.ejml.data.DenseMatrix64F matrix)
x
, y
, z
,
s
in order from the given matrix.
The quaternion is immediately normalized.
matrix
- the dense-matrix containing this quaternion's components. Not modified.public Quaternion(Orientation3DReadOnly orientation)
orientation
- the orientation to initialize this quaternion. Not modified.public Quaternion(QuaternionReadOnly other)
other
.other
- the quaternion to copy the components from. Not modified.public Quaternion(Tuple4DReadOnly other)
other
.other
- the tuple to copy the components from. Not modified.public Quaternion(Vector3DReadOnly rotationVector)
rotationVector
.
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.
rotationVector
- the rotation vector to initialize this quaternion. Not modified.public Quaternion(double yaw, double pitch, double roll)
yaw
, pitch
, and roll
.yaw
- the angle to rotate about the z-axis.pitch
- the angle to rotate about the y-axis.roll
- the angle to rotate about the x-axis.public void set(Quaternion other)
other
.set
in interface Settable<Quaternion>
other
- the other quaternion to copy the values from. Not modified.public void setUnsafe(double qx, double qy, double qz, double qs)
This method is meant for internal usage. Prefer using
QuaternionBasics.set(double, double, double, double)
.
setUnsafe
in interface QuaternionBasics
qx
- the x-component of this quaternion.qy
- the y-component of this quaternion.qz
- the z-component of this quaternion.qs
- the s-component of this quaternion.public double getX()
getX
in interface Tuple4DReadOnly
public double getY()
getY
in interface Tuple4DReadOnly
public double getZ()
getZ
in interface Tuple4DReadOnly
public double getS()
getS
in interface Tuple4DReadOnly
public boolean equals(java.lang.Object object)
object
's class is the same as this, in which case the method
returns Tuple4DReadOnly.equals(Tuple4DReadOnly)
, it returns false
otherwise.equals
in class java.lang.Object
object
- the object to compare against this. Not modified.true
if object
and this are exactly equal, false
otherwise.public boolean epsilonEquals(Quaternion other, double epsilon)
other
to an
epsilon
.epsilonEquals
in interface EpsilonComparable<Quaternion>
other
- the other quaternion to compare against this. Not modified.epsilon
- the tolerance to use when comparing each component.true
if the two tuples are equal, false
otherwise.public boolean geometricallyEquals(Quaternion 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.
geometricallyEquals
in interface GeometricallyComparable<Quaternion>
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.public java.lang.String toString()
String
representation of this quaternion as follows: (x, y, z, s).toString
in class java.lang.Object
String
representing this quaternion.public int hashCode()
hashCode
in class java.lang.Object