@EqualityStructural @Immutable public final class QuaternionI4F extends Object implements QuaternionReadable4FType
float elements.
Values of this type are immutable and can therefore be safely accessed from multiple threads.
| Modifier and Type | Class and Description |
|---|---|
static class |
QuaternionI4F.ContextQI4F
The ContextQM4F type contains the minimum storage required for all of the
functions of the
QuaternionM4F class. |
| Modifier and Type | Field and Description |
|---|---|
static QuaternionI4F |
IDENTITY
The "identity" quaternion, [0.0 0.0 0.0 1.0]
|
| Constructor and Description |
|---|
QuaternionI4F()
Default constructor, initializing the quaternion with values
[0.0,
0.0, 0.0, 1.0] |
QuaternionI4F(float in_x,
float in_y,
float in_z,
float in_w)
Construct a quaternion initialized with the given values.
|
QuaternionI4F(QuaternionReadable4FType q)
Construct a quaternion initialized with the values contained in
q. |
| Modifier and Type | Method and Description |
|---|---|
static QuaternionI4F |
add(QuaternionReadable4FType q0,
QuaternionReadable4FType q1)
Calculate the element-wise sum of the quaternions
q0 and q1. |
static boolean |
almostEqual(com.io7m.jequality.AlmostEqualFloat.ContextRelative context,
QuaternionReadable4FType qa,
QuaternionReadable4FType qb)
Determine whether or not the quaternions
qa and qb are
equal to within the degree of error given in context. |
static QuaternionI4F |
conjugate(QuaternionReadable4FType q)
Calculate the conjugate of the input quaternion
q. |
static float |
dotProduct(QuaternionReadable4FType q0,
QuaternionReadable4FType q1)
Calculate the scalar product of the quaternions
q0 and q1. |
boolean |
equals(Object obj) |
float |
getWF() |
float |
getXF() |
float |
getYF() |
float |
getZF() |
int |
hashCode() |
static QuaternionI4F |
interpolateLinear(QuaternionReadable4FType q0,
QuaternionReadable4FType q1,
float alpha)
Linearly interpolate between
q0 and q1 by the amount alpha, such that:
interpolateLinear(q0, q1, 0.0) = q0 interpolateLinear(q0, q1, 1.0) = q1 |
static boolean |
isNegationOf(com.io7m.jequality.AlmostEqualFloat.ContextRelative context,
QuaternionReadable4FType qa,
QuaternionReadable4FType qb)
Return
true iff qa is the negation of qb. |
static QuaternionI4F |
lookAtWithContext(QuaternionI4F.ContextQI4F context,
VectorReadable3FType origin,
VectorReadable3FType target,
VectorReadable3FType up)
Produce a quaternion that represents a rotation that "looks at" the point
at
target assuming the viewer is at origin, using up as the "up" vector. |
static float |
magnitude(QuaternionReadable4FType q)
Calculate the magnitude of the quaternion
q. |
static float |
magnitudeSquared(QuaternionReadable4FType q)
Calculate the squared magnitude of the quaternion
q. |
static QuaternionI4F |
makeFromAxisAngle(VectorReadable3FType axis,
double angle)
Produce a quaternion that represents a rotation of
angle degrees
around the axis specified by axis. |
static QuaternionI4F |
makeFromRotationMatrix3x3(MatrixReadable3x3FType m)
Produce a quaternion equivalent to the rotation matrix
m. |
static QuaternionI4F |
makeFromRotationMatrix4x4(MatrixReadable4x4FType m)
Produce a quaternion equivalent to the rotation matrix
m, writing
the result to out. |
static <M extends MatrixWritable3x3FType> |
makeRotationMatrix3x3(QuaternionReadable4FType q,
M m)
Produce a rotation matrix from the quaternion
q, saving the result
to m. |
static <M extends MatrixWritable4x4FType> |
makeRotationMatrix4x4(QuaternionReadable4FType q,
M m)
Produce a rotation matrix from the quaternion
q, saving the result
to m. |
static QuaternionI4F |
multiply(QuaternionReadable4FType q0,
QuaternionReadable4FType q1)
Multiply the quaternion
q0 by the quaternion q1 . |
static QuaternionI4F |
negate(QuaternionReadable4FType q)
Negate the elements of
q. |
static QuaternionI4F |
normalize(QuaternionReadable4FType q)
Normalize the quaternion
q, preserqing its direction but reducing
it to unit length. |
static QuaternionI4F |
scale(QuaternionReadable4FType q,
float r)
Scale the quaternion
q by the scalar r. |
static QuaternionI4F |
subtract(QuaternionReadable4FType q0,
QuaternionReadable4FType q1)
Subtract the quaternion
q0 from the quaternion q1. |
String |
toString() |
public static final QuaternionI4F IDENTITY
public QuaternionI4F()
[0.0,
0.0, 0.0, 1.0]public QuaternionI4F(float in_x,
float in_y,
float in_z,
float in_w)
in_x - The x valuein_y - The y valuein_z - The z valuein_w - The w valuepublic QuaternionI4F(QuaternionReadable4FType q)
q.q - The source quaternionpublic static QuaternionI4F add(QuaternionReadable4FType q0, QuaternionReadable4FType q1)
q0 and q1.q0 - The left input quaternionq1 - The right input quaternion(q0.x + q1.x, q0.y + q1.y, q0.z + q1.z, q0.w + q1.w)public static boolean almostEqual(com.io7m.jequality.AlmostEqualFloat.ContextRelative context,
QuaternionReadable4FType qa,
QuaternionReadable4FType qb)
qa and qb are
equal to within the degree of error given in context.context - The equality contextqa - The left input quaternionqb - The right input quaterniontrue if the quaternions are almost equalAlmostEqualFloat.almostEqual(ContextRelative, float, float)public static QuaternionI4F conjugate(QuaternionReadable4FType q)
q.q - The input quaternionpublic static float dotProduct(QuaternionReadable4FType q0, QuaternionReadable4FType q1)
q0 and q1.q0 - The left input quaternionq1 - The right input quaternionpublic static QuaternionI4F interpolateLinear(QuaternionReadable4FType q0, QuaternionReadable4FType q1, float alpha)
q0 and q1 by the amount alpha, such that:
interpolateLinear(q0, q1, 0.0) = q0interpolateLinear(q0, q1, 1.0) = q1q0 - The left input quaternionq1 - The right input quaternionalpha - The interpolation value, between 0.0 and 1.0(1 - alpha) * q0 + alpha * q1public static boolean isNegationOf(com.io7m.jequality.AlmostEqualFloat.ContextRelative context,
QuaternionReadable4FType qa,
QuaternionReadable4FType qb)
true iff qa is the negation of qb.
Each element is compared with (ContextRelative, float, float).
context - The equality contextqa - The left quaternionqb - The right quaterniontrue iff qa is the negation of qbpublic static QuaternionI4F lookAtWithContext(QuaternionI4F.ContextQI4F context, VectorReadable3FType origin, VectorReadable3FType target, VectorReadable3FType up)
target assuming the viewer is at origin, using up as the "up" vector.
The function uses storage preallocated in context to avoid any
new allocations.
context - Preallocated storageorigin - The origin pointtarget - The target pointup - The up vectorpublic static float magnitude(QuaternionReadable4FType q)
q.
Correspondingly, magnitude(normalize(q)) == 1.0.q - The input quaternionpublic static float magnitudeSquared(QuaternionReadable4FType q)
q.q - The input quaternionpublic static QuaternionI4F makeFromAxisAngle(VectorReadable3FType axis, double angle)
angle degrees
around the axis specified by axis. axis is assumed to be of
unit length.axis - The normalized vector representing the axisangle - The angle to rotate, in radiansVectorI3F.normalize(VectorReadable3FType),
VectorI4F.normalize(VectorReadable4FType),
VectorM3F.normalize(VectorReadable3FType, VectorWritable3FType),
VectorM4F.normalize(VectorReadable4FType, VectorWritable4FType)public static QuaternionI4F makeFromRotationMatrix3x3(MatrixReadable3x3FType m)
m.m - The rotation matrixpublic static QuaternionI4F makeFromRotationMatrix4x4(MatrixReadable4x4FType m)
m, writing
the result to out.m - The rotation matrixpublic static <M extends MatrixWritable3x3FType> M makeRotationMatrix3x3(QuaternionReadable4FType q, M m)
q, saving the result
to m.M - The precise type of writable matrix.q - The input quaternionm - The output matrixmpublic static <M extends MatrixWritable4x4FType> M makeRotationMatrix4x4(QuaternionReadable4FType q, M m)
q, saving the result
to m.M - The precise type of matrixq - The input quaternionm - The output matrixmpublic static QuaternionI4F multiply(QuaternionReadable4FType q0, QuaternionReadable4FType q1)
q0 by the quaternion q1 .
Note that this operation is not commutative.
The function is most often used to concatenate quaternions to combine rotations. As an example, assuming that:
qx represents some rotation around the X axisqy represents some rotation around the Y axisqz represents some rotation around the Z axis The following code produces a quaternion qr1 that represents a
rotation around the X axis, followed by a rotation around the Y axis,
followed by a rotation around the Z axis:
qr0 = QuaternionI4F.multiply(qy, qx); qr1 = QuaternionI4F
.multiply(qz, qy); q0 - The left input quaternionq1 - The right input quaternionpublic static QuaternionI4F negate(QuaternionReadable4FType q)
q.q - The source quaternionqpublic static QuaternionI4F normalize(QuaternionReadable4FType q)
q, preserqing its direction but reducing
it to unit length.q - The input quaternionq but with
magnitude equal to 1.0public static QuaternionI4F scale(QuaternionReadable4FType q, float r)
q by the scalar r.q - The input quaternionr - The scaling value(q.x * r, q.y * r, q.z * r, q.w * r)public static QuaternionI4F subtract(QuaternionReadable4FType q0, QuaternionReadable4FType q1)
q0 from the quaternion q1.q0 - The left input quaternionq1 - The right input quaternion(q0.x - q1.x, q0.y - q1.y, q0.z - q1.z)public float getWF()
getWF in interface VectorReadable4FTypepublic float getXF()
getXF in interface VectorReadable2FTypepublic float getYF()
getYF in interface VectorReadable2FTypepublic float getZF()
getZF in interface VectorReadable3FTypeCopyright © 2016 <code@io7m.com> http://io7m.com