QuaternionBasics
, QuaternionReadOnly
, Tuple4DBasics
, Vector4DBasics
, Vector4DReadOnly
Quaternion
, Quaternion32
, Vector4D
, Vector4D32
public interface Tuple4DReadOnly
A tuple 4D represents what is commonly called a quaternion. Although from definition, a
quaternion does not necessarily represent an 3D orientation, in this library the classes
implementing QuaternionReadOnly
and QuaternionBasics
represent unit-quaternions
meant to represent 3D orientations. The classes implementing Vector4DReadOnly
and
Vector4DBasics
are used to represent generic quaternions.
When describing a 4D tuple, its 4 components are often gathered in two groups: the scalar part
s
and the vector part (x
, y
, z
).
Note on the difference between applying a 3D transform on a quaternion and a 4D vector:
s
remains unchanged. The vector part (x
, y
, z
) is scaled and rotated, and
translated by s
times the translation part of the transform. Note that for s = 0
,
a 4D vector behaves as a 3D vector, and for s = 1
it behaves as a 3D point.
Modifier and Type | Method | Description |
---|---|---|
default boolean |
containsNaN() |
Tests if this tuple contains a
Double.NaN . |
default double |
dot(Tuple4DReadOnly other) |
Calculates and returns the value of the dot product of this tuple with
other . |
default boolean |
epsilonEquals(Tuple4DReadOnly other,
double epsilon) |
Tests on a per component basis if this tuple is equal to the given
other to an
epsilon . |
default boolean |
equals(Tuple4DReadOnly other) |
Tests on a per component basis, if this tuple is exactly equal to
other . |
default void |
get(double[] tupleArrayToPack) |
Packs the components
x , y , z , s in order in an array starting
from its first index. |
default void |
get(float[] tupleArrayToPack) |
Packs the components
x , y , z , s in order in an array starting
from its first index. |
default void |
get(int startIndex,
double[] tupleArrayToPack) |
Packs the components
x , y , z , s in order in an array starting
from startIndex . |
default void |
get(int startIndex,
float[] tupleArrayToPack) |
Packs the components
x , y , z , s in order in an array starting
from startIndex . |
default void |
get(int startRow,
int column,
org.ejml.data.DenseMatrix64F tupleMatrixToPack) |
Packs the components
x , y , z , s in order in a column vector
starting from startRow at the column index column . |
default void |
get(int startRow,
org.ejml.data.DenseMatrix64F tupleMatrixToPack) |
Packs the components
x , y , z , s in order in a column vector
starting from startRow . |
default void |
get(org.ejml.data.DenseMatrix64F tupleMatrixToPack) |
Packs the components
x , y , z , s in order in a column vector
starting from its first row index. |
default double |
getElement(int index) |
Selects a component of this tuple based on
index and returns its value. |
default double |
getElement32(int index) |
Selects a component of this tuple based on
index and returns its value. |
double |
getS() |
Returns the s-component of this tuple.
|
default float |
getS32() |
Returns the s-component of this tuple.
|
double |
getX() |
Returns the x-component of this tuple.
|
default float |
getX32() |
Returns the x-component of this tuple.
|
double |
getY() |
Returns the y-component of this tuple.
|
default float |
getY32() |
Returns the y-component of this tuple.
|
double |
getZ() |
Returns the z-component of this tuple.
|
default float |
getZ32() |
Returns the z-component of this tuple.
|
default double |
norm() |
Calculates and returns the norm of this tuple.
|
default double |
normSquared() |
Calculates and returns the square of the norm of this tuple.
|
double getX()
double getY()
double getZ()
double getS()
default float getX32()
default float getY32()
default float getZ32()
default float getS32()
default boolean containsNaN()
Double.NaN
.true
if this tuple contains a Double.NaN
, false
otherwise.default double getElement(int index)
index
and returns its value.
For an index
value going from 0 up to 3, the corresponding components are x
,
y
, z
, and s
, respectively.
index
- the index of the component to get.java.lang.IndexOutOfBoundsException
- if index
∉ [0, 3].default double getElement32(int index)
index
and returns its value.
For an index
value going from 0 up to 3, the corresponding components are x
,
y
, z
, and s
, respectively.
index
- the index of the component to get.java.lang.IndexOutOfBoundsException
- if index
∉ [0, 3].default void get(double[] tupleArrayToPack)
x
, y
, z
, s
in order in an array starting
from its first index.tupleArrayToPack
- the array in which this tuple is stored. Modified.default void get(int startIndex, double[] tupleArrayToPack)
x
, y
, z
, s
in order in an array starting
from startIndex
.startIndex
- the index in the array where the first component is stored.tupleArrayToPack
- the array in which this tuple is stored. Modified.default void get(float[] tupleArrayToPack)
x
, y
, z
, s
in order in an array starting
from its first index.tupleArrayToPack
- the array in which this tuple is stored. Modified.default void get(int startIndex, float[] tupleArrayToPack)
x
, y
, z
, s
in order in an array starting
from startIndex
.startIndex
- the index in the array where the first component is stored.tupleArrayToPack
- the array in which this tuple is stored. Modified.default void get(org.ejml.data.DenseMatrix64F tupleMatrixToPack)
x
, y
, z
, s
in order in a column vector
starting from its first row index.tupleMatrixToPack
- the array in which this tuple is stored. Modified.default void get(int startRow, org.ejml.data.DenseMatrix64F tupleMatrixToPack)
x
, y
, z
, s
in order in a column vector
starting from startRow
.startRow
- the first row index to start writing in the dense-matrix.tupleMatrixToPack
- the column vector in which this tuple is stored. Modified.default void get(int startRow, int column, org.ejml.data.DenseMatrix64F tupleMatrixToPack)
x
, y
, z
, s
in order in a column vector
starting from startRow
at the column index column
.startRow
- the first row index to start writing in the dense-matrix.column
- the column index to write in the dense-matrix.tupleMatrixToPack
- the matrix in which this tuple is stored. Modified.default double norm()
norm = √(x2 + y2 + z2 + s2)
default double normSquared()
norm2 = x2 + y2 + z2 + s2
This method is usually preferred over norm()
when calculation speed matters and
knowledge of the actual norm does not, i.e. when comparing several tuples by theirs norm.
default double dot(Tuple4DReadOnly other)
other
.
For instance, the dot product of two tuples p and q is defined as:
p . q = ∑i=1:4(pi * qi)
other
- the other vector used for the dot product. Not modified.default boolean epsilonEquals(Tuple4DReadOnly other, double epsilon)
other
to an
epsilon
.other
- the other tuple to compare against this. Not modified.epsilon
- the tolerance to use when comparing each component.true
if the two tuples are equal, false
otherwise.default boolean equals(Tuple4DReadOnly other)
other
.other
- the other tuple to compare against this. Not modified.true
if the two tuples are exactly equal component-wise, false
otherwise.