public final class QuaternionM4F extends Object implements Quaternion4FType
float elements.
Values of this type cannot be accessed safely from multiple threads without explicit synchronization.
| Modifier and Type | Class and Description |
|---|---|
static class |
QuaternionM4F.ContextQM4F
The ContextQM4F type contains the minimum storage required for all of
the functions of the
QuaternionM4D class. |
| Constructor and Description |
|---|
QuaternionM4F()
Default constructor, initializing the quaternion with values
[0.0,
0.0, 0.0, 1.0] |
QuaternionM4F(float in_x,
float in_y,
float in_z,
float in_w)
Construct a quaternion initialized with the given values.
|
QuaternionM4F(QuaternionReadable4FType q)
Construct a quaternion initialized with the values given in
q. |
| Modifier and Type | Method and Description |
|---|---|
static <Q extends QuaternionWritable4FType> |
add(QuaternionReadable4FType q0,
QuaternionReadable4FType q1,
Q out)
Calculate the element-wise sum of the quaternions
q0 and q1, saving the result to qr. |
static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> |
addInPlace(Q q0,
QuaternionReadable4FType q1)
Calculate the element-wise sum of the quaternions
q0 and q1, saving the result to q0. |
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 <Q extends QuaternionWritable4FType & QuaternionReadable4FType> |
conjugate(QuaternionReadable4FType q,
Q out)
Calculate the conjugate of the input quaternion
q, saving the
result to out. |
static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> |
conjugateInPlace(Q q)
Calculate the conjugate of the input quaternion
q, modifying q in place. |
static <Q extends QuaternionWritable4FType> |
copy(QuaternionReadable4FType q,
Q out)
Copy the contents of the quaternion
q to out. |
void |
copyFrom2F(VectorReadable2FType in_v)
Set the current vector to the contents of the input vector.
|
void |
copyFrom3F(VectorReadable3FType in_v)
Set the current vector to the contents of the input vector.
|
void |
copyFrom4F(VectorReadable4FType in_v)
Set the current vector to the contents of the input vector.
|
static double |
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 <Q extends QuaternionWritable4FType> |
interpolateLinear(QuaternionM4F.ContextQM4F c,
QuaternionReadable4FType q0,
QuaternionReadable4FType q1,
double alpha,
Q r)
Linearly interpolate between
q0 and q1 by the amount alpha, such that:
interpolateLinear(q0, q1, 0.0, r) -> r = q0
interpolateLinear(q0, q1, 1.0, r) -> r = q1 |
static <Q extends QuaternionWritable4FType> |
interpolateSphericalLinear(QuaternionM4F.ContextQM4F c,
QuaternionReadable4FType q0,
QuaternionReadable4FType q1,
float alpha,
Q r)
Linearly interpolate between
q0 and q1 by the amount alpha, such that:
interpolateSphericalLinear(q0, q1, 0.0, r) -> r = q0
interpolateSphericalLinear(q0, q1, 1.0, r) -> r = q1
|
static boolean |
isNegationOf(com.io7m.jequality.AlmostEqualFloat.ContextRelative context,
QuaternionReadable4FType qa,
QuaternionReadable4FType qb)
Return
true iff qa is the negation of qb. |
static <Q extends QuaternionWritable4FType> |
lookAt(QuaternionM4F.ContextQM4F context,
VectorReadable3FType origin,
VectorReadable3FType target,
VectorReadable3FType up,
Q q)
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, saving the result to q. |
static double |
magnitude(QuaternionReadable4FType q)
Calculate the magnitude of the quaternion
q. |
static double |
magnitudeSquared(QuaternionReadable4FType q)
Calculate the squared magnitude of the quaternion
q. |
static <Q extends QuaternionWritable4FType> |
makeFromAxisAngle(VectorReadable3FType axis,
double angle,
Q out)
Produce a quaternion that represents a rotation of
angle degrees
around the axis specified by axis, saving the result to out. |
static <Q extends QuaternionWritable4FType> |
makeFromRotationMatrix3x3(MatrixReadable3x3FType m,
Q out)
Produce a quaternion equivalent to the rotation matrix
m, writing
the result to out. |
static <Q extends QuaternionWritable4FType> |
makeFromRotationMatrix4x4(MatrixReadable4x4FType m,
Q out)
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 <Q extends QuaternionWritable4FType> |
multiply(QuaternionReadable4FType q0,
QuaternionReadable4FType q1,
Q qr)
Multiply the quaternion
q0 by the quaternion q1 , saving
the result to qr. |
static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> |
multiplyInPlace(Q q0,
QuaternionReadable4FType q1)
Multiply the quaternion
q0 by the quaternion q1 , saving
the result to q0. |
static <Q extends QuaternionWritable4FType> |
negate(QuaternionReadable4FType qa,
Q out)
Negate the elements of
qa, writing the resulting quaternion to
out. |
static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> |
negateInPlace(Q q)
Negate the elements of
q, modifying the quaternion in-place. |
static <Q extends QuaternionWritable4FType> |
normalize(QuaternionReadable4FType q,
Q out)
Returns a quaternion with the same orientation as
q but with
magnitude equal to 1.0 in out. |
static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> |
normalizeInPlace(Q q)
Returns a quaternion with the same orientation as
q but with
magnitude equal to 1.0 in q. |
static <Q extends QuaternionWritable4FType> |
scale(QuaternionReadable4FType q,
double r,
Q out)
Scale the quaternion
q by the scalar r, saving the result
to out. |
static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> |
scaleInPlace(Q q,
double r)
Scale the quaternion
q by the scalar r, saving the result
to q. |
void |
set2F(float in_x,
float in_y)
Set the current
x and y values of the current vector. |
void |
set3F(float in_x,
float in_y,
float in_z)
Set the current
x, y and z values of the current
vector. |
void |
set4F(float in_x,
float in_y,
float in_z,
float in_w)
Set the current
x, y, z and w values of the
current vector. |
void |
setWF(float in_w)
Set the current
w value of the current vector. |
void |
setXF(float in_x)
Set the current
x value of the current vector. |
void |
setYF(float in_y)
Set the current
y value of the current vector. |
void |
setZF(float in_z)
Set the current
z value of the current vector. |
static <Q extends QuaternionWritable4FType> |
subtract(QuaternionReadable4FType q0,
QuaternionReadable4FType q1,
Q out)
Subtract the quaternion
q0 from the quaternion q1, saving
the result to out. |
static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> |
subtractInPlace(Q q0,
QuaternionReadable4FType q1)
Subtract the quaternion
q0 from the quaternion q1, saving
the result to q0. |
static <V extends VectorWritable3FType> |
toAxisAngle(QuaternionReadable4FType q,
V out)
Determine the axis-angle representation of the given quaternion.
|
String |
toString() |
public QuaternionM4F()
[0.0,
0.0, 0.0, 1.0]public QuaternionM4F(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 QuaternionM4F(QuaternionReadable4FType q)
q.q - The source quaternionpublic static <Q extends QuaternionWritable4FType> Q add(QuaternionReadable4FType q0, QuaternionReadable4FType q1, Q out)
q0 and q1, saving the result to qr.Q - The precise type of quaternionq0 - The left input quaternionq1 - The right input quaternionout - The output quaternion(q0.x + q1.x, q0.y + q1.y, q0.z + q1.z, q0.w + q1.w)public static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> Q addInPlace(Q q0, QuaternionReadable4FType q1)
q0 and q1, saving the result to q0.Q - The precise type of quaternionq0 - 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 <Q extends QuaternionWritable4FType & QuaternionReadable4FType> Q conjugate(QuaternionReadable4FType q, Q out)
q, saving the
result to out.Q - The precise type of quaternionq - The input quaternionout - The output quaternionoutpublic static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> Q conjugateInPlace(Q q)
q, modifying q in place.Q - The precise type of quaternionq - The input quaternionqpublic static <Q extends QuaternionWritable4FType> Q copy(QuaternionReadable4FType q, Q out)
q to out.Q - The precise type of quaternionq - The input quaternionout - The output quaternionoutpublic static double dotProduct(QuaternionReadable4FType q0, QuaternionReadable4FType q1)
q0 and q1.q0 - The left input quaternionq1 - The right input quaternionpublic static <Q extends QuaternionWritable4FType> Q interpolateLinear(QuaternionM4F.ContextQM4F c, QuaternionReadable4FType q0, QuaternionReadable4FType q1, double alpha, Q r)
q0 and q1 by the amount alpha, such that:
interpolateLinear(q0, q1, 0.0, r) -> r = q0interpolateLinear(q0, q1, 1.0, r) -> r = q1Q - The precise type of quaternionc - Preallocated storageq0 - The left input quaternionq1 - The right input quaternionalpha - The interpolation value, between 0.0 and 1.0r - The output quaternion(1 - alpha) * q0 + alpha * q1public static <Q extends QuaternionWritable4FType> Q interpolateSphericalLinear(QuaternionM4F.ContextQM4F c, QuaternionReadable4FType q0, QuaternionReadable4FType q1, float alpha, Q r)
q0 and q1 by the amount alpha, such that:
interpolateSphericalLinear(q0, q1, 0.0, r) -> r = q0interpolateSphericalLinear(q0, q1, 1.0, r) -> r = q1Note that unlike simple linear interpolation, this function is guaranteed to return a normalized quaternion.
Q - The precise type of quaternionc - Preallocated storageq0 - The left input quaternionq1 - The right input quaternionalpha - The interpolation value, between 0.0 and 1.0r - The output quaternionq0 and
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 <Q extends QuaternionWritable4FType> Q lookAt(QuaternionM4F.ContextQM4F context, VectorReadable3FType origin, VectorReadable3FType target, VectorReadable3FType up, Q q)
target assuming the viewer is at origin, using up as the "up" vector, saving the result to q.
The function uses storage preallocated in context to avoid any
new allocations.
Q - The precise type of quaternioncontext - Preallocated storageq - The output quaternionorigin - The origin pointtarget - The target pointup - The up vectorqpublic static double magnitude(QuaternionReadable4FType q)
q.
Correspondingly, magnitude(normalize(q)) == 1.0.q - The input quaternionpublic static double magnitudeSquared(QuaternionReadable4FType q)
q.q - The input quaternionpublic static <Q extends QuaternionWritable4FType> Q makeFromAxisAngle(VectorReadable3FType axis, double angle, Q out)
angle degrees
around the axis specified by axis, saving the result to out. axis is assumed to be of unit length.Q - The precise type of quaternionaxis - The normalized vector representing the axisangle - The angle to rotate, in radiansout - The output quaternionVectorI3F.normalize(VectorReadable3FType),
VectorI4F.normalize(VectorReadable4FType),
VectorM3F.normalize(VectorReadable3FType, VectorWritable3FType),
VectorM4F.normalize(VectorReadable4FType, VectorWritable4FType)public static <Q extends QuaternionWritable4FType> Q makeFromRotationMatrix3x3(MatrixReadable3x3FType m, Q out)
m, writing
the result to out.Q - The precise type of quaternionm - The rotation matrixout - The output quaternionoutpublic static <Q extends QuaternionWritable4FType> Q makeFromRotationMatrix4x4(MatrixReadable4x4FType m, Q out)
m, writing
the result to out.Q - The precise type of quaternionm - The rotation matrixout - The output quaternionoutpublic static <M extends MatrixWritable3x3FType> M makeRotationMatrix3x3(QuaternionReadable4FType q, M m)
q, saving the result
to m.M - The precise type of matrixq - 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 matrix.q - The input quaternionm - The output matrixmpublic static <Q extends QuaternionWritable4FType> Q multiply(QuaternionReadable4FType q0, QuaternionReadable4FType q1, Q qr)
q0 by the quaternion q1 , saving
the result to qr.
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 qr that represents a
rotation around the X axis, followed by a rotation around the Y axis,
followed by a rotation around the Z axis:
QuaternionM4F qr = new QuaternionM4F(); QuaternionM4F.multiply(qy,
qx, qr); QuaternionM4F.multiply(qz, qr, qr); Q - The precise type of quaternionq0 - The left input quaternionq1 - The right input quaternionqr - The output quaternionqrpublic static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> Q multiplyInPlace(Q q0, QuaternionReadable4FType q1)
q0 by the quaternion q1 , saving
the result to q0.Q - The precise type of quaternionq0 - The left quaternionq1 - The right quaternionmultiply(QuaternionReadable4FType,
QuaternionReadable4FType, QuaternionWritable4FType)public static <Q extends QuaternionWritable4FType> Q negate(QuaternionReadable4FType qa, Q out)
qa, writing the resulting quaternion to
out.Q - The precise type of quaternionqa - The input quaternionout - The output quaternionpublic static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> Q negateInPlace(Q q)
q, modifying the quaternion in-place.Q - The precise type of quaternionq - The input quaternionpublic static <Q extends QuaternionWritable4FType> Q normalize(QuaternionReadable4FType q, Q out)
q but with
magnitude equal to 1.0 in out. The function returns the
zero quaternion iff the input is the zero quaternion.Q - The precise type of quaternionout - The output quaternionq - The input quaternionpublic static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> Q normalizeInPlace(Q q)
q but with
magnitude equal to 1.0 in q. The function returns the zero
quaternion iff the input is the zero quaternion.Q - The precise type of quaternionq - The input quaternionpublic static <Q extends QuaternionWritable4FType> Q scale(QuaternionReadable4FType q, double r, Q out)
q by the scalar r, saving the result
to out.Q - The precise type of quaternionq - The input quaternionr - The scaling valueout - The output quaternion(q.x * r, q.y * r, q.z * r, q.w * r)public static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> Q scaleInPlace(Q q, double r)
q by the scalar r, saving the result
to q.Q - The precise type of quaternionq - The input quaternionr - The scaling value(q.x * r, q.y * r, q.z * r, q.w * r)public static <Q extends QuaternionWritable4FType> Q subtract(QuaternionReadable4FType q0, QuaternionReadable4FType q1, Q out)
q0 from the quaternion q1, saving
the result to out.Q - The precise type of quaternionq0 - The left input quaternionq1 - The right input quaternionout - The output quaternion(q0.x - q1.x, q0.y - q1.y, q0.z - q1.z, q0.w - q1.w)public static <Q extends QuaternionWritable4FType & QuaternionReadable4FType> Q subtractInPlace(Q q0, QuaternionReadable4FType q1)
q0 from the quaternion q1, saving
the result to q0.Q - The precise type of quaternionq0 - 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 <V extends VectorWritable3FType> double toAxisAngle(QuaternionReadable4FType q, V out)
V - The precise type of output vectorq - The input quaternionout - The output vector that will contain the axispublic void copyFrom2F(VectorReadable2FType in_v)
VectorWritable2FTypecopyFrom2F in interface VectorWritable2FTypein_v - The input vectorpublic void copyFrom3F(VectorReadable3FType in_v)
VectorWritable3FTypecopyFrom3F in interface VectorWritable3FTypein_v - The input vectorpublic void copyFrom4F(VectorReadable4FType in_v)
VectorWritable4FTypecopyFrom4F in interface VectorWritable4FTypein_v - The input vectorpublic float getWF()
getWF in interface VectorReadable4FTypepublic void setWF(float in_w)
VectorWritable4FTypew value of the current vector.setWF in interface VectorWritable4FTypein_w - The new w value.public float getXF()
getXF in interface VectorReadable2FTypepublic void setXF(float in_x)
VectorWritable2FTypex value of the current vector.setXF in interface VectorWritable2FTypein_x - The new x value.public float getYF()
getYF in interface VectorReadable2FTypepublic void setYF(float in_y)
VectorWritable2FTypey value of the current vector.setYF in interface VectorWritable2FTypein_y - The new y value.public float getZF()
getZF in interface VectorReadable3FTypepublic void setZF(float in_z)
VectorWritable3FTypez value of the current vector.setZF in interface VectorWritable3FTypein_z - The new z value.public void set2F(float in_x,
float in_y)
VectorWritable2FTypex and y values of the current vector.set2F in interface VectorWritable2FTypein_x - The new x value.in_y - The new y value.public void set3F(float in_x,
float in_y,
float in_z)
VectorWritable3FTypex, y and z values of the current
vector.set3F in interface VectorWritable3FTypein_x - The new x value.in_y - The new y value.in_z - The new z value.public void set4F(float in_x,
float in_y,
float in_z,
float in_w)
VectorWritable4FTypex, y, z and w values of the
current vector.set4F in interface VectorWritable4FTypein_x - The new x value.in_y - The new y value.in_z - The new z value.in_w - The new w value.Copyright © 2017 <code@io7m.com> http://io7m.com