-
- All Superinterfaces:
Cloneable
,Serializable
public interface Quaternion extends Cloneable, Serializable
A 4 element unit quaternion represented by x, y, z, w coordinates. The quaternion is always normalized.Other Rotation Representations
Other representations of an rotation are available from this class: axis-angle, and Euler angles.
Axis Angles
The axis–angle representation of a rotation parameterizes a rotation in a three-dimensional Euclidean space by two values: a unit vector, indicating the direction of an axis of rotation, and an angle describing the magnitude of the rotation about the axis. The rotation occurs in the sense prescribed by the (left/right)-hand rule.Euler Angles
The term "Euler Angle" is used for any representation of 3 dimensional rotations where the rotation is decomposed into 3 separate angles.There is no single set of conventions and standards in this area, therefore the following conventions was choosen:
- angle applied first: heading;
- angle applied second: attitude;
- angle applied last: bank
Examples: NASA aircraft standard and telescope standard
- Version:
- 17.0 2020-01-04 14:41:43
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathgeom
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Quaternion.AxisAngle
A representation of axis-angle.static class
Quaternion.EulerAngles
A representation of Euler Angles.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
conjugate()
Sets the value of this quaternion to the conjugate of itself.void
conjugate(Quaternion q1)
Sets the value of this quaternion to the conjugate of quaternion q1.boolean
epsilonEquals(Quaternion t1, double epsilon)
Returns true if the L-infinite distance between this tuple and tuple t1 is less than or equal to the epsilon parameter, otherwise returns false.double
getAngle()
Replies the rotation angle represented by this quaternion.Vector3D<?,?>
getAxis()
Replies the rotation axis-angle represented by this quaternion.Quaternion.AxisAngle
getAxisAngle()
Replies the rotation axis represented by this quaternion.Quaternion.EulerAngles
getEulerAngles()
Replies the Euler's angles that corresponds to the quaternion.Quaternion.EulerAngles
getEulerAngles(CoordinateSystem3D system)
Replies the Euler's angles that corresponds to the quaternion.double
getW()
Replies the W coordinate.double
getX()
Replies the X coordinate.double
getY()
Replies the Y coordinate.double
getZ()
Replies the Z coordinate.void
interpolate(Quaternion q1, double alpha)
Performs a great circle interpolation between this quaternion and the quaternion parameter and places the result into this quaternion.void
interpolate(Quaternion q1, Quaternion q2, double alpha)
Performs a great circle interpolation between quaternion q1 and quaternion q2 and places the result into this quaternion.void
inverse()
Sets the value of this quaternion to the quaternion inverse of itself.void
inverse(Quaternion q1)
Sets the value of this quaternion to quaternion inverse of quaternion q1.void
mul(Quaternion q1)
Sets the value of this quaternion to the quaternion product of itself and q1 (this = this * q1).void
mul(Quaternion q1, Quaternion q2)
Sets the value of this quaternion to the quaternion product of quaternions q1 and q2 (this = q1 * q2).void
mulInverse(Quaternion q1)
Multiplies this quaternion by the inverse of quaternion q1 and places the value into this quaternion.void
mulInverse(Quaternion q1, Quaternion q2)
Multiplies quaternion q1 by the inverse of quaternion q2 and places the value into this quaternion.void
normalize()
Normalizes the value of this quaternion in place.void
normalize(Quaternion q1)
Sets the value of this quaternion to the normalized value of quaternion q1.void
set(double x, double y, double z, double w)
Set the quaternion coordinates.void
set(Quaternion quat)
Set the quaternion coordinates.void
setAxisAngle(double x1, double y1, double z1, double angle)
Sets the value of this quaternion to the equivalent rotation of the Axis-Angle arguments.void
setAxisAngle(Vector3D<?,?> axis, double angle)
Sets the value of this quaternion to the equivalent rotation of the Axis-Angle arguments.void
setEulerAngles(double attitude, double bank, double heading)
Set the quaternion with the Euler angles.void
setEulerAngles(double attitude, double bank, double heading, CoordinateSystem3D system)
Set the quaternion with the Euler angles.void
setEulerAngles(Quaternion.EulerAngles angles)
Set the quaternion with the Euler angles.void
setFromMatrix(Matrix3d m1)
Sets the value of this quaternion to the rotational component of the passed matrix.void
setFromMatrix(Matrix4d m1)
Sets the value of this quaternion to the rotational component of the passed matrix.void
setW(double w)
Set the W coordinate.void
setX(double x)
Set the X coordinate.void
setY(double y)
Set the Y coordinate.void
setZ(double z)
Set the Z coordinate.
-
-
-
Method Detail
-
getX
@Pure double getX()
Replies the X coordinate.- Returns:
- x
-
setX
void setX(double x)
Set the X coordinate.- Parameters:
x
- x coordinate.
-
getY
@Pure double getY()
Replies the Y coordinate.- Returns:
- y
-
setY
void setY(double y)
Set the Y coordinate.- Parameters:
y
- y coordinate.
-
getZ
@Pure double getZ()
Replies the Z coordinate.- Returns:
- z
-
setZ
void setZ(double z)
Set the Z coordinate.- Parameters:
z
- z coordinate.
-
getW
@Pure double getW()
Replies the W coordinate.- Returns:
- w
-
setW
void setW(double w)
Set the W coordinate.- Parameters:
w
- w coordinate.
-
epsilonEquals
@Pure boolean epsilonEquals(Quaternion t1, double epsilon)
Returns true if the L-infinite distance between this tuple and tuple t1 is less than or equal to the epsilon parameter, otherwise returns false. The L-infinite distance is equal to MAX[abs(x1-x2), abs(y1-y2)].- Parameters:
t1
- the tuple to be compared to this tupleepsilon
- the threshold value- Returns:
- true or false
-
conjugate
void conjugate(Quaternion q1)
Sets the value of this quaternion to the conjugate of quaternion q1.- Parameters:
q1
- the source vector
-
conjugate
void conjugate()
Sets the value of this quaternion to the conjugate of itself.
-
mul
void mul(Quaternion q1, Quaternion q2)
Sets the value of this quaternion to the quaternion product of quaternions q1 and q2 (this = q1 * q2). Note that this is safe for aliasing (e.g. this can be q1 or q2).- Parameters:
q1
- the first quaternionq2
- the second quaternion
-
mul
void mul(Quaternion q1)
Sets the value of this quaternion to the quaternion product of itself and q1 (this = this * q1).- Parameters:
q1
- the other quaternion
-
mulInverse
void mulInverse(Quaternion q1, Quaternion q2)
Multiplies quaternion q1 by the inverse of quaternion q2 and places the value into this quaternion. The value of both argument quaternions is preservered (this = q1 * q2^-1).- Parameters:
q1
- the first quaternionq2
- the second quaternion
-
mulInverse
void mulInverse(Quaternion q1)
Multiplies this quaternion by the inverse of quaternion q1 and places the value into this quaternion. The value of the argument quaternion is preserved (this = this * q^-1).- Parameters:
q1
- the other quaternion
-
inverse
void inverse(Quaternion q1)
Sets the value of this quaternion to quaternion inverse of quaternion q1.- Parameters:
q1
- the quaternion to be inverted
-
inverse
void inverse()
Sets the value of this quaternion to the quaternion inverse of itself.
-
normalize
void normalize(Quaternion q1)
Sets the value of this quaternion to the normalized value of quaternion q1.- Parameters:
q1
- the quaternion to be normalized.
-
normalize
void normalize()
Normalizes the value of this quaternion in place.
-
setFromMatrix
void setFromMatrix(Matrix4d m1)
Sets the value of this quaternion to the rotational component of the passed matrix.- Parameters:
m1
- the Matrix4f
-
setFromMatrix
void setFromMatrix(Matrix3d m1)
Sets the value of this quaternion to the rotational component of the passed matrix.- Parameters:
m1
- the Matrix3f
-
set
void set(double x, double y, double z, double w)
Set the quaternion coordinates.- Parameters:
x
- x coordinate.y
- y coordinate.z
- z coordinate.w
- w coordinate.
-
set
void set(Quaternion quat)
Set the quaternion coordinates.- Parameters:
quat
- the quaternion to copy.
-
setAxisAngle
void setAxisAngle(Vector3D<?,?> axis, double angle)
Sets the value of this quaternion to the equivalent rotation of the Axis-Angle arguments.- Parameters:
axis
- is the axis of rotation.angle
- is the rotation around the axis.
-
setAxisAngle
void setAxisAngle(double x1, double y1, double z1, double angle)
Sets the value of this quaternion to the equivalent rotation of the Axis-Angle arguments.- Parameters:
x1
- is the x coordinate of the rotation axisy1
- is the y coordinate of the rotation axisz1
- is the z coordinate of the rotation axisangle
- is the rotation around the axis.
-
getAxis
@Pure Vector3D<?,?> getAxis()
Replies the rotation axis-angle represented by this quaternion.- Returns:
- the rotation axis-angle.
-
getAngle
@Pure double getAngle()
Replies the rotation angle represented by this quaternion.- Returns:
- the rotation axis
- See Also:
setAxisAngle(Vector3D, double)
,setAxisAngle(double, double, double, double)
,getAxis()
-
getAxisAngle
@Pure Quaternion.AxisAngle getAxisAngle()
Replies the rotation axis represented by this quaternion.- Returns:
- the rotation axis
- See Also:
setAxisAngle(Vector3D, double)
,setAxisAngle(double, double, double, double)
,getAngle()
-
interpolate
void interpolate(Quaternion q1, double alpha)
Performs a great circle interpolation between this quaternion and the quaternion parameter and places the result into this quaternion.- Parameters:
q1
- the other quaternionalpha
- the alpha interpolation parameter
-
interpolate
void interpolate(Quaternion q1, Quaternion q2, double alpha)
Performs a great circle interpolation between quaternion q1 and quaternion q2 and places the result into this quaternion.- Parameters:
q1
- the first quaternionq2
- the second quaternionalpha
- the alpha interpolation parameter
-
setEulerAngles
void setEulerAngles(Quaternion.EulerAngles angles)
Set the quaternion with the Euler angles.- Parameters:
angles
- the Euler angles.- See Also:
- Euler Angles, Euler to Quaternion
-
setEulerAngles
void setEulerAngles(double attitude, double bank, double heading)
Set the quaternion with the Euler angles. Thedefault coordinate system
is used from applying the Euler angles.- Parameters:
attitude
- is the rotation around left vector.bank
- is the rotation around front vector.heading
- is the rotation around top vector.- See Also:
CoordinateSystem3D.getDefaultCoordinateSystem()
, Euler Angles, Euler to Quaternion
-
setEulerAngles
void setEulerAngles(double attitude, double bank, double heading, CoordinateSystem3D system)
Set the quaternion with the Euler angles.- Parameters:
attitude
- is the rotation around left vector.bank
- is the rotation around front vector.heading
- is the rotation around top vector.system
- the coordinate system to use for applying the Euler angles.- See Also:
- Euler Angles, Euler to Quaternion
-
getEulerAngles
@Pure Quaternion.EulerAngles getEulerAngles()
Replies the Euler's angles that corresponds to the quaternion. Thedefault coordinate system
is used from applying the Euler angles.- Returns:
- the heading, attitude and bank angles.
- See Also:
CoordinateSystem3D.getDefaultCoordinateSystem()
, Euler Angles, Quaternion to Euler
-
getEulerAngles
@Pure Quaternion.EulerAngles getEulerAngles(CoordinateSystem3D system)
Replies the Euler's angles that corresponds to the quaternion.- Parameters:
system
- is the coordinate system used to define the up, left and front vectors.- Returns:
- the heading, attitude and bank angles.
- See Also:
- Euler Angles, Quaternion to Euler
-
-