8 this->
W = quaternion.
W;
9 this->
X = quaternion.
X;
10 this->
Y = quaternion.
Y;
11 this->
Z = quaternion.
Z;
36 float s2 =
q.W * 2.0f;
37 float dPUV = (
q.X *
v.X +
q.Y *
v.Y) * 2.0f;
38 float dPUU =
q.W *
q.W - (
q.X *
q.X +
q.Y *
q.Y +
q.Z *
q.Z);
50 float s2 =
q.W * 2.0f;
51 float dPUV = (
q.X *
v.X +
q.Y *
v.Y) * 2.0f;
52 float dPUU =
q.W *
q.W - (
q.X *
q.X +
q.Y *
q.Y +
q.Z *
q.Z);
107 q1U =
q1U.UnitQuaternion();
108 q2U =
q2U.UnitQuaternion();
113 q1U =
q1U.AdditiveInverse();
118 return (
q1U.Add( (
q2U.Subtract(
q1U)).Multiply(ratio) )).UnitQuaternion();
122 dot = Mathematics::Constrain<float>(
dot, -1, 1);
131 return q1U.Multiply(f1).Add(
q2U.Multiply(f2)).UnitQuaternion();
190 float32_t multA[
multBlockSize] = {
W,
W,
W,
W,
X,
X,
X,
X,
Y,
Y,
Y,
Y,
Z,
Z,
Z,
Z};
350 return (
W *
q.W) + (
X *
q.X) + (
Y *
q.Y) + (
Z *
q.Z);
375 return W != 0 &&
X != 0 &&
Y != 0 &&
Z != 0;
402 return "[" + w +
", " +
x +
", " +
y +
", " +
z +
"]";
407 return this->
IsEqual(quaternion);
411 return !(this->
IsEqual(quaternion));
415 this->
W = quaternion.
W;
416 this->
X = quaternion.
X;
417 this->
Y = quaternion.
Y;
418 this->
Z = quaternion.
Z;
460 return q1.Subtract(
q2);
464 return q1.Multiply(
q2);
468 return q1.Divide(
q2);
476 return q1.DotProduct(
q2);
Quaternion operator*(const float &scalar, const Quaternion &q)
Defines the Quaternion class for 3D rotations and transformations.
Implements a generic Kalman Filter for 1D data.
static float Sqrt(float value)
Computes the square root of a value.
static bool IsClose(float v1, float v2, float epsilon)
Checks if two values are close within a specified epsilon.
static String DoubleToCleanString(float value)
Converts a floating-point value to a String, removing trailing decimals if not needed.
static bool IsFinite(float value)
Checks if a floating-point value is finite.
static float Pow(float value, float exponent)
Raises a value to a given exponent.
static bool IsInfinite(float value)
Checks if a floating-point value is infinite.
static const float EPSILON
A small constant used for floating-point comparisons.
static bool IsNaN(float value)
Checks if a floating-point value is NaN (Not a Number).
A mathematical construct representing a rotation in 3D space.
Vector3D GetBiVector() const
Retrieves the bi-vector (X, Y, Z) portion of the quaternion (with W=0).
float DotProduct(const Quaternion &q) const
Computes the dot product between this quaternion and another.
Quaternion Power(const Quaternion &exponent) const
Raises this quaternion to the power of another quaternion (component-wise).
bool IsFinite() const
Checks if all components are finite.
Quaternion Divide(const Quaternion &quaternion) const
Divides this quaternion by another quaternion component-wise (not a typical quaternion operation).
static Quaternion SphericalInterpolation(const Quaternion &q1, const Quaternion &q2, const float &ratio)
Performs spherical linear interpolation (slerp) between two quaternions.
Quaternion Conjugate() const
Returns the conjugate of this quaternion (W stays the same, X/Y/Z get negated).
bool IsInfinite() const
Checks if any component is infinite.
Quaternion AdditiveInverse() const
Negates each component (an additive inverse).
Quaternion UnitQuaternion() const
Returns a unit quaternion (normalized) version of this quaternion.
bool IsNaN() const
Checks if any component of this quaternion is NaN.
Quaternion operator/(const Quaternion &quaternion) const
Divides this quaternion by another quaternion, component-wise.
Quaternion operator+(const Quaternion &quaternion) const
Adds two quaternions (component-wise).
Quaternion operator-(const Quaternion &quaternion) const
Subtracts one quaternion from another (component-wise).
bool operator==(const Quaternion &quaternion) const
Equality operator. Checks if two quaternions match exactly (component-wise).
Quaternion()
Default constructor. Initializes the quaternion to identity (1,0,0,0).
bool operator!=(const Quaternion &quaternion) const
Inequality operator. Checks if two quaternions differ in any component.
Quaternion MultiplicativeInverse() const
Returns the multiplicative inverse of this quaternion, such that q * q^-1 = identity.
Quaternion DeltaRotation(const Vector3D &angularVelocity, const float &timeDelta) const
Computes a small rotation quaternion given an angular velocity and time delta.
Quaternion Permutate(const Vector3D &permutation) const
Performs a permutation operation using a 3D vector (custom transform).
Vector2D RotateVector(const Vector2D &v) const
Rotates a 2D vector by this quaternion, projecting it in 2D.
Vector2D RotateVectorUnit(const Vector2D &v, const Quaternion &q) const
Rotates a 2D vector by a unit quaternion (assumes normalized), allowing a different quaternion to be ...
float W
Scalar part of the quaternion.
bool IsEqual(const Quaternion &quaternion) const
Checks if two quaternions are exactly equal (component-wise).
String ToString() const
Converts this quaternion to a string representation (e.g. "(W, X, Y, Z)").
bool IsClose(const Quaternion &quaternion, const float &epsilon) const
Checks if two quaternions are nearly equal within a tolerance.
float Z
Z component of the quaternion's vector part.
float X
X component of the quaternion's vector part.
Vector3D GetNormal() const
Retrieves the normal vector part of the quaternion, typically its axis of rotation.
float Normal() const
Computes the quaternion's norm (equivalent to squared magnitude).
float Y
Y component of the quaternion's vector part.
Quaternion Absolute() const
Returns a quaternion where each component is the absolute value of the original.
Quaternion Add(const Quaternion &quaternion) const
Adds two quaternions component-wise.
Vector2D UnrotateVector(const Vector2D &coordinate) const
Applies the inverse of this quaternion's rotation to a 2D vector.
friend Quaternion operator*(const float &scalar, const Quaternion &q)
Scalar multiplication operator (on the left).
float Magnitude() const
Computes the magnitude (length) of this quaternion.
Quaternion Multiply(const Quaternion &quaternion) const
Multiplies (composes) this quaternion with another (order matters).
Quaternion operator=(const Quaternion &quaternion)
Assignment operator. Copies another quaternion's components to this one.
bool IsNonZero() const
Checks if the quaternion is non-zero (i.e., any component != 0).
Quaternion Subtract(const Quaternion &quaternion) const
Subtracts a quaternion from this quaternion component-wise.
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
float Z
The Z-component of the 3D vector.
float X
The X-component of the 3D vector.
float Y
The Y-component of the 3D vector.