Table of Contents

Class QuaternionAssertions

Namespace
MathAssertions.TUnit
Assembly
MathAssertions.TUnit.dll

Fluent Quaternion assertions. Distinguishes component-wise equality (treats q and -q as different) from rotational equivalence (treats them as the same rotation, the SO(3) double-cover view).

public static class QuaternionAssertions
Inheritance
QuaternionAssertions
Inherited Members

Remarks

v0.2.0 enriches the failure messages for IsApproximatelyEqualTo(Quaternion, Quaternion, double) and IsRotationallyEquivalentTo(Quaternion, Quaternion, double) with per-component delta rendering via MathAssertions.MathFailureMessage. v0.2.0 also adds HasAxisAngleApproximately(Quaternion, Vector3, double, double) for axis-angle-form rotation assertions.

Methods

HasAxisAngleApproximately(Quaternion, Vector3, double, double)

Asserts the quaternion, viewed as a rotation in axis-angle form, lies within tolerance of the rotation expectedAngleDegrees degrees around expectedAxis. Handles the SO(3) double cover so a q / -q pair both compare equivalent to the same axis-angle pair. See HasAxisAngleApproximately(Quaternion, Vector3, double, double) for the full contract.

[GenerateAssertion(InlineMethodBody = true)]
public static AssertionResult HasAxisAngleApproximately(this Quaternion value, Vector3 expectedAxis, double expectedAngleDegrees, double tolerance)

Parameters

value Quaternion
expectedAxis Vector3
expectedAngleDegrees double
tolerance double

Returns

AssertionResult

IsApproximatelyEqualTo(Quaternion, Quaternion, double)

Component-wise tolerance comparison.

[GenerateAssertion(InlineMethodBody = true)]
public static AssertionResult IsApproximatelyEqualTo(this Quaternion value, Quaternion expected, double tolerance)

Parameters

value Quaternion
expected Quaternion
tolerance double

Returns

AssertionResult

IsIdentity(Quaternion, double)

Asserts the quaternion is the identity quaternion within tolerance.

[GenerateAssertion(ExpectationMessage = "to be the identity quaternion within tolerance {tolerance}", InlineMethodBody = true)]
public static bool IsIdentity(this Quaternion value, double tolerance)

Parameters

value Quaternion
tolerance double

Returns

bool

IsNormalized(Quaternion, double)

Asserts the quaternion has unit length within tolerance.

[GenerateAssertion(ExpectationMessage = "to be a unit quaternion within tolerance {tolerance}", InlineMethodBody = true)]
public static bool IsNormalized(this Quaternion value, double tolerance)

Parameters

value Quaternion
tolerance double

Returns

bool

IsRotationallyEquivalentTo(Quaternion, Quaternion, double)

Asserts the quaternion encodes the same rotation as expected within tolerance, treating q and -q as equivalent.

[GenerateAssertion(InlineMethodBody = true)]
public static AssertionResult IsRotationallyEquivalentTo(this Quaternion value, Quaternion expected, double tolerance)

Parameters

value Quaternion
expected Quaternion
tolerance double

Returns

AssertionResult