Clearable
, EpsilonComparable<Quaternion32>
, GeometricallyComparable<Quaternion32>
, GeometryObject<Quaternion32>
, Settable<Quaternion32>
, Transformable
, Orientation3DBasics
, Orientation3DReadOnly
, QuaternionBasics
, QuaternionReadOnly
, Tuple4DBasics
, Tuple4DReadOnly
public class Quaternion32 extends java.lang.Object implements QuaternionBasics, GeometryObject<Quaternion32>
This version of quaternion uses double precision fields to save the value of each component. It
is meant for garbage free usage and for situations where heap memory is limited. When memory is
not a constraint, the use of Vector2D32
is preferable.
ORIENTATION_2D_EPSILON
EPS_POW
EPS_UNITARY, GEOMETRICALLY_EQUALS_THRESHOLD
Constructor | Description |
---|---|
Quaternion32() |
Creates a new quaternion and initializes it to the neutral quaternion which represents a
'zero' rotation.
|
Quaternion32(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 . |
Quaternion32(float[] quaternionArray) |
Creates a new quaternion and initializes its component
x , y , z ,
s in order from the given array. |
Quaternion32(float x,
float y,
float z,
float s) |
Creates a new quaternion and initializes it with the given components.
|
Quaternion32(Orientation3DReadOnly orientation) |
Creates a new quaternion and initializes such that it represents the same orientation as the
given one.
|
Quaternion32(Vector3DReadOnly rotationVector) |
Creates a new quaternion and initializes such that it represents the same orientation as the
given
rotationVector . |
Modifier and Type | Method | Description |
---|---|---|
boolean |
epsilonEquals(Quaternion32 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(Quaternion32 other,
double epsilon) |
Tests if
this and other represent the same orientation to an epsilon . |
double |
getS() |
Returns the s-component of this tuple.
|
float |
getS32() |
Returns the s-component of this tuple.
|
double |
getX() |
Returns the x-component of this tuple.
|
float |
getX32() |
Returns the x-component of this tuple.
|
double |
getY() |
Returns the y-component of this tuple.
|
float |
getY32() |
Returns the y-component of this tuple.
|
double |
getZ() |
Returns the z-component of this tuple.
|
float |
getZ32() |
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(Quaternion32 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, normSquared
public Quaternion32()
public Quaternion32(float x, float y, float z, float s)
The quaternion is immediately normalized.
x
- the x-component.y
- the y-component.z
- the z-component.s
- the s-component.public Quaternion32(float[] 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 Quaternion32(Orientation3DReadOnly orientation)
orientation
- the orientation used to initialize this quaternion. Not modified.public Quaternion32(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 Quaternion32(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(Quaternion32 other)
other
.set
in interface Settable<Quaternion32>
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 float getX32()
getX32
in interface Tuple4DReadOnly
public float getY32()
getY32
in interface Tuple4DReadOnly
public float getZ32()
getZ32
in interface Tuple4DReadOnly
public float getS32()
getS32
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(Quaternion32 other, double epsilon)
other
to an
epsilon
.epsilonEquals
in interface EpsilonComparable<Quaternion32>
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(Quaternion32 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<Quaternion32>
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