Package civitas.celestis.math.decimal
Class DecimalQuaternion
java.lang.Object
civitas.celestis.util.tuple.Object4<BigDecimal>
civitas.celestis.math.decimal.Decimal4
civitas.celestis.math.decimal.DecimalQuaternion
- All Implemented Interfaces:
DecimalVector<Decimal4,,Vector4> BigVector<BigDecimal,,BigDecimal, Decimal4, Decimal4, Vector4> BaseTuple<BigDecimal>,Tuple<BigDecimal>,Serializable,Iterable<BigDecimal>
An immutable decimal quaternion.
- See Also:
-
Field Summary
FieldsFields inherited from class civitas.celestis.math.decimal.Decimal4
NEGATIVE_A, NEGATIVE_B, NEGATIVE_C, NEGATIVE_D, POSITIVE_A, POSITIVE_B, POSITIVE_C, POSITIVE_D, ZERO -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new decimal quaternion.Creates a new decimal quaternion.DecimalQuaternion(Tuple<? extends BigDecimal> t) Creates a new decimal quaternion.DecimalQuaternion(BigDecimal[] components) Creates a new decimal quaternion.Creates a new decimal quaternion.DecimalQuaternion(BigDecimal a, BigDecimal b, BigDecimal c, BigDecimal d) Creates a new decimal quaternion. -
Method Summary
Modifier and TypeMethodDescriptionAdds another quaternion to this quaternion, then returns the resulting quaternion.add(BigDecimal s) Adds a scalar to this quaternion, then returns the resulting quaternion.Returns the conjugate of this quaternion.divide(BigDecimal s) Divides this quaternion by a scalar, then returns the resulting quaternion.inverse()Returns the inverse of this quaternion.Multiplies this quaternion by the provided quaternionq.negate()Negates this quaternion, then returns the negated quaternion.Normalizes this quaternion to have a Euclidean norm (magnitude) of1.Normalizes this quaternion to have a Euclidean norm (magnitude) of1.Normalizes this quaternion to have a Euclidean norm (magnitude) of1.scalar()Returns the scalar part of this quaternion.scale(BigDecimal s) Scales the rotation of this quaternion, then returns the resulting quaternion.Subtracts this quaternion by another quaternion, then returns the resulting quaternion.Subtracts this quaternion by a scalar, then returns the resulting quaternion.vector()Returns the vector part of this quaternion.Methods inherited from class civitas.celestis.math.decimal.Decimal4
add, bigIntegerValue, clamp, distance, distance2, distanceManhattan, dot, equals, max, merge, min, multiply, norm, norm2, normalizeOrDefault, normalizeOrZero, normManhattan, primValue, requireNonNull, subtract, transformMethods inherited from class civitas.celestis.util.tuple.Object4
a, array, b, c, contains, containsAll, d, equals, forEach, forEach, get, hashCode, iterator, list, map, mapToDouble, mapToFloat, mapToInt, mapToLong, merge, size, stream, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
spliterator
-
Field Details
-
IDENTITY
The identity quaternion. This will produce no rotation.
-
-
Constructor Details
-
DecimalQuaternion
public DecimalQuaternion(@Nonnull BigDecimal a, @Nonnull BigDecimal b, @Nonnull BigDecimal c, @Nonnull BigDecimal d) Creates a new decimal quaternion.- Parameters:
a- The A component (the scalar part) of this quaternionb- The B component (the vector's A component) of this quaternionc- The C component (the vector's B component) of this quaterniond- The D component (the vector's C component) of this quaternion
-
DecimalQuaternion
Creates a new decimal quaternion.- Parameters:
s- The scalar part of this quaternion.v- The vector part of this quaternion
-
DecimalQuaternion
Creates a new decimal quaternion.- Parameters:
components- An array containing the components of this quaternion in ABCD order- Throws:
IllegalArgumentException- When the provided array's length is not4
-
DecimalQuaternion
Creates a new decimal quaternion.- Parameters:
t- The tuple of which to copy component values from- Throws:
IllegalArgumentException- When the provided tuplet's size is not4
-
DecimalQuaternion
Creates a new decimal quaternion.- Parameters:
v- The vector of which to copy component values from
-
DecimalQuaternion
Creates a new decimal quaternion.- Parameters:
q- The quaternion of which to copy component values from
-
-
Method Details
-
scalar
Returns the scalar part of this quaternion.- Returns:
- The scalar part of this quaternion
-
vector
Returns the vector part of this quaternion.- Returns:
- The vector part of this quaternion
-
add
Adds a scalar to this quaternion, then returns the resulting quaternion.- Specified by:
addin interfaceBigVector<BigDecimal,BigDecimal, Decimal4, Decimal4, Vector4> - Overrides:
addin classDecimal4- Parameters:
s- The scalar of which to add to this quaternion- Returns:
- The resulting quaternion
-
subtract
Subtracts this quaternion by a scalar, then returns the resulting quaternion.- Specified by:
subtractin interfaceBigVector<BigDecimal,BigDecimal, Decimal4, Decimal4, Vector4> - Overrides:
subtractin classDecimal4- Parameters:
s- The scalar of which to subtract this quaternion by- Returns:
- The resulting quaternion
-
scale
Scales the rotation of this quaternion, then returns the resulting quaternion. This will only work properly if this quaternion is a rotation quaternion. (a quaternion with a Euclidean norm of1)- Parameters:
s- The scale factor to apply to the rotation- Returns:
- The scaled quaternion
-
divide
Divides this quaternion by a scalar, then returns the resulting quaternion.- Specified by:
dividein interfaceBigVector<BigDecimal,BigDecimal, Decimal4, Decimal4, Vector4> - Overrides:
dividein classDecimal4- Parameters:
s- The scalar of which to divide each component of this quaternion by- Returns:
- The resulting quaternion
- Throws:
ArithmeticException- When the denominatorsis zero
-
add
Adds another quaternion to this quaternion, then returns the resulting quaternion.- Parameters:
q- The quaternion of which to add to this quaternion- Returns:
- The resulting quaternion
-
subtract
Subtracts this quaternion by another quaternion, then returns the resulting quaternion.- Parameters:
q- The quaternion of which to subtract from this quaternion- Returns:
- The resulting quaternion
-
multiply
Multiplies this quaternion by the provided quaternionq.- Parameters:
q- The quaternion of which to multiply this quaternion by- Returns:
- The quaternion left-product of the two quaternions
-
conjugate
Returns the conjugate of this quaternion.- Returns:
- The conjugate of this quaternion
-
inverse
Returns the inverse of this quaternion.- Returns:
- The inverse of this quaternion
- Throws:
ArithmeticException- When the squared Euclidean norm (the squared magnitude) of this quaternion is zero
-
negate
Negates this quaternion, then returns the negated quaternion.- Specified by:
negatein interfaceBigVector<BigDecimal,BigDecimal, Decimal4, Decimal4, Vector4> - Overrides:
negatein classDecimal4- Returns:
- The negation of this quaternion
-
normalize
Normalizes this quaternion to have a Euclidean norm (magnitude) of1.- Specified by:
normalizein interfaceBigVector<BigDecimal,BigDecimal, Decimal4, Decimal4, Vector4> - Overrides:
normalizein classDecimal4- Returns:
- The normalized quaternion of this quaternion
- Throws:
ArithmeticException- When the Euclidean norm of this quaternion is zero
-
normalizeOrIdentity
Normalizes this quaternion to have a Euclidean norm (magnitude) of1. If this quaternion has no direction (the Euclidean norm is zero), this will the identity quaternion. (IDENTITY)- Returns:
- The normalized quaternion of this quaternion if successful,
the identity quaternionotherwise
-
normalizeOrDefault
Normalizes this quaternion to have a Euclidean norm (magnitude) of1. If this quaternion has no direction (the Euclidean norm is zero), this will return the provided fallback valueqinstead of throwing an exception.- Parameters:
q- The fallback value to default to when normalization is impossible- Returns:
- The normalized quaternion of this quaternion if successful, the fallback value otherwise
-