public class QuaternionM4F extends Object implements QuaternionReadable4FType, QuaternionWritable4FType
Values of this type cannot be accessed safely from multiple threads without explicit synchronization.
| Modifier and Type | Class and Description |
|---|---|
static class |
QuaternionM4F.Context
The Context 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 QuaternionM4F |
add(QuaternionReadable4FType q0,
QuaternionReadable4FType q1,
QuaternionM4F out)
Calculate the element-wise sum of the quaternions
q0 and
q1, saving the result to qr. |
static QuaternionM4F |
addInPlace(QuaternionM4F 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 QuaternionM4F |
conjugate(QuaternionReadable4FType q,
QuaternionM4F out)
Calculate the conjugate of the input quaternion
q, saving
the result to out. |
static QuaternionM4F |
conjugateInPlace(QuaternionM4F q)
Calculate the conjugate of the input quaternion
q, modifying
q in place. |
static QuaternionM4F |
copy(QuaternionReadable4FType q,
QuaternionM4F 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 QuaternionM4F |
interpolateLinear(QuaternionReadable4FType q0,
QuaternionReadable4FType q1,
double alpha,
QuaternionM4F 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 boolean |
isNegationOf(com.io7m.jequality.AlmostEqualFloat.ContextRelative context,
QuaternionReadable4FType qa,
QuaternionReadable4FType qb)
Return
true iff qa is the negation of
qb. |
static QuaternionM4F |
lookAtWithContext(QuaternionM4F.Context context,
VectorReadable3FType origin,
VectorReadable3FType target,
VectorReadable3FType up,
QuaternionM4F 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 QuaternionM4F |
makeFromAxisAngle(VectorReadable3FType axis,
double angle,
QuaternionM4F out)
Produce a quaternion that represents a rotation of
angle
degrees around the axis specified by axis, saving the result
to out. |
static QuaternionM4F |
makeFromRotationMatrix3x3(MatrixReadable3x3FType m,
QuaternionM4F out)
Produce a quaternion equivalent to the rotation matrix
m,
writing the result to out. |
static QuaternionM4F |
makeFromRotationMatrix4x4(MatrixReadable4x4FType m,
QuaternionM4F out)
Produce a quaternion equivalent to the rotation matrix
m,
writing the result to out. |
static MatrixM3x3F |
makeRotationMatrix3x3(QuaternionM4F q,
MatrixM3x3F m)
Produce a rotation matrix from the quaternion
q, saving the
result to m. |
static MatrixM4x4F |
makeRotationMatrix4x4(QuaternionReadable4FType q,
MatrixM4x4F m)
Produce a rotation matrix from the quaternion
q, saving the
result to m. |
static QuaternionM4F |
multiply(QuaternionReadable4FType q0,
QuaternionReadable4FType q1,
QuaternionM4F qr)
Multiply the quaternion
q0 by the quaternion q1
, saving the result to qr. |
static QuaternionM4F |
multiplyInPlace(QuaternionM4F q0,
QuaternionReadable4FType q1)
Multiply the quaternion
q0 by the quaternion q1
, saving the result to q0. |
static QuaternionM4F |
negate(QuaternionReadable4FType qa,
QuaternionM4F out)
Negate the elements of
qa, writing the resulting quaternion
to out. |
static QuaternionM4F |
negateInPlace(QuaternionM4F q)
Negate the elements of
q, modifying the quaternion in-place. |
static QuaternionM4F |
normalize(QuaternionReadable4FType q,
QuaternionM4F out)
Returns a quaternion with the same orientation as
q but with
magnitude equal to 1.0 in out. |
static QuaternionM4F |
normalizeInPlace(QuaternionM4F q)
Returns a quaternion with the same orientation as
q but with
magnitude equal to 1.0 in q. |
static QuaternionM4F |
scale(QuaternionReadable4FType q,
double r,
QuaternionM4F out)
Scale the quaternion
q by the scalar r, saving
the result to out. |
static QuaternionM4F |
scaleInPlace(QuaternionM4F 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 QuaternionM4F |
subtract(QuaternionReadable4FType q0,
QuaternionReadable4FType q1,
QuaternionM4F out)
Subtract the quaternion
q0 from the quaternion
q1, saving the result to out. |
static QuaternionM4F |
subtractInPlace(QuaternionM4F q0,
QuaternionReadable4FType q1)
Subtract the quaternion
q0 from the quaternion
q1, saving the result to q0. |
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 final QuaternionM4F add(QuaternionReadable4FType q0, QuaternionReadable4FType q1, QuaternionM4F out)
q0 and
q1, saving the result to qr.q0 - 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 final QuaternionM4F addInPlace(QuaternionM4F q0, QuaternionReadable4FType q1)
q0 and
q1, saving the result to q0.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 final 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 final QuaternionM4F conjugate(QuaternionReadable4FType q, QuaternionM4F out)
q, saving
the result to out.q - The input quaternionout - The output quaternionoutpublic static final QuaternionM4F conjugateInPlace(QuaternionM4F q)
q, modifying
q in place.q - The input quaternionqpublic static final QuaternionM4F copy(QuaternionReadable4FType q, QuaternionM4F out)
q to out.q - The input quaternionout - The output quaternionoutpublic static final double dotProduct(QuaternionReadable4FType q0, QuaternionReadable4FType q1)
q0 and
q1.q0 - The left input quaternionq1 - The right input quaternionpublic static final QuaternionM4F interpolateLinear(QuaternionReadable4FType q0, QuaternionReadable4FType q1, double alpha, QuaternionM4F r)
q0 and q1 by the
amount alpha, such that:
interpolateLinear(q0, q1, 0.0, r) -> r = q0interpolateLinear(q0, q1, 1.0, r) -> r = q1q0 - 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 final 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
AlmostEqualFloat.almostEqual(ContextRelative, float, float).
context - The equality contextqa - The left quaternionqb - The right quaterniontrue iff qa is the negation of
qbpublic static final QuaternionM4F lookAtWithContext(QuaternionM4F.Context context, VectorReadable3FType origin, VectorReadable3FType target, VectorReadable3FType up, QuaternionM4F 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.
context - Preallocated storageq - The output quaternionorigin - The origin pointtarget - The target pointup - The up vectorqpublic static final double magnitude(QuaternionReadable4FType q)
q.
Correspondingly, magnitude(normalize(q)) == 1.0.q - The input quaternionpublic static final double magnitudeSquared(QuaternionReadable4FType q)
q.q - The input quaternionpublic static final QuaternionM4F makeFromAxisAngle(VectorReadable3FType axis, double angle, QuaternionM4F out)
angle
degrees around the axis specified by axis, saving the result
to out. axis is assumed to be of unit length.axis - The normalized vector representing the axisangle - The angle to rotate, in radiansout - The output quaternionVectorI3F.normalize(VectorReadable3FType),
VectorI4F.normalize(VectorReadable4FType),
VectorM3F.normalize(VectorReadable3FType, VectorM3F),
VectorM4F.normalize(VectorReadable4FType, VectorM4F)public static final QuaternionM4F makeFromRotationMatrix3x3(MatrixReadable3x3FType m, QuaternionM4F out)
m,
writing the result to out.m - The rotation matrixout - The output quaternionoutpublic static final QuaternionM4F makeFromRotationMatrix4x4(MatrixReadable4x4FType m, QuaternionM4F out)
m,
writing the result to out.m - The rotation matrixout - The output quaternionoutpublic static final MatrixM3x3F makeRotationMatrix3x3(QuaternionM4F q, MatrixM3x3F m)
q, saving the
result to m.q - The input quaternionm - The output matrixmpublic static final MatrixM4x4F makeRotationMatrix4x4(QuaternionReadable4FType q, MatrixM4x4F m)
q, saving the
result to m.q - The input quaternionm - The output matrixmpublic static final QuaternionM4F multiply(QuaternionReadable4FType q0, QuaternionReadable4FType q1, QuaternionM4F 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);
q0 - The left input quaternionq1 - The right input quaternionqr - The output quaternionqrpublic static final QuaternionM4F multiplyInPlace(QuaternionM4F q0, QuaternionReadable4FType q1)
q0 by the quaternion q1
, saving the result to q0.q0 - The left quaternionq1 - The right quaternionmultiply(QuaternionReadable4FType,
QuaternionReadable4FType, QuaternionM4F)public static final QuaternionM4F negate(QuaternionReadable4FType qa, QuaternionM4F out)
qa, writing the resulting quaternion
to out.qa - The input quaternionout - The output quaternionpublic static final QuaternionM4F negateInPlace(QuaternionM4F q)
q, modifying the quaternion in-place.q - The input quaternionpublic static final QuaternionM4F normalize(QuaternionReadable4FType q, QuaternionM4F out)
q but with
magnitude equal to 1.0 in out. The function
returns the zero quaternion iff the input is the zero quaternion.out - The output quaternionq - The input quaternionpublic static final QuaternionM4F normalizeInPlace(QuaternionM4F 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 input quaternionpublic static final QuaternionM4F scale(QuaternionReadable4FType q, double r, QuaternionM4F out)
q by the scalar r, saving
the result to out.q - The input quaternionr - The scaling valueout - The output quaternion(q.x * r, q.y * r, q.z * r, q.w * r)public static final QuaternionM4F scaleInPlace(QuaternionM4F q, double r)
q by the scalar r, saving
the result to q.q - The input quaternionr - The scaling value(q.x * r, q.y * r, q.z * r, q.w * r)public static final QuaternionM4F subtract(QuaternionReadable4FType q0, QuaternionReadable4FType q1, QuaternionM4F out)
q0 from the quaternion
q1, saving the result to out.q0 - 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 final QuaternionM4F subtractInPlace(QuaternionM4F q0, QuaternionReadable4FType q1)
q0 from the quaternion
q1, saving the result to q0.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 final void copyFrom2F(VectorReadable2FType in_v)
VectorWritable2FTypecopyFrom2F in interface VectorWritable2FTypein_v - The input vectorpublic final void copyFrom3F(VectorReadable3FType in_v)
VectorWritable3FTypecopyFrom3F in interface VectorWritable3FTypein_v - The input vectorpublic final void copyFrom4F(VectorReadable4FType in_v)
VectorWritable4FTypecopyFrom4F in interface VectorWritable4FTypein_v - The input vectorpublic final float getWF()
getWF in interface VectorReadable4FTypepublic final float getXF()
getXF in interface VectorReadable2FTypepublic final float getYF()
getYF in interface VectorReadable2FTypepublic final float getZF()
getZF in interface VectorReadable3FTypepublic final 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 final 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 final 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.public final void setWF(float in_w)
VectorWritable4FTypew value of the current vector.setWF in interface VectorWritable4FTypein_w - The new w value.public final void setXF(float in_x)
VectorWritable2FTypex value of the current vector.setXF in interface VectorWritable2FTypein_x - The new x value.public final void setYF(float in_y)
VectorWritable2FTypey value of the current vector.setYF in interface VectorWritable2FTypein_y - The new y value.public final void setZF(float in_z)
VectorWritable3FTypez value of the current vector.setZF in interface VectorWritable3FTypein_z - The new z value.Copyright © 2014 <code@io7m.com> http://io7m.com