Class PoseRenderer
- Namespace
- MathAssertions.Render
- Assembly
- MathAssertions.dll
Pure renderer that converts a 3D pose — a Vector3 position and / or a
Quaternion orientation — into deterministic, snapshot-friendly text.
Position renders as pos: (x, y, z) tol=t and orientation as
quat: (x, y, z, w) tol=t, each on its own LF-terminated line; the full-pose
overload emits both.
public static class PoseRenderer
- Inheritance
-
PoseRenderer
- Inherited Members
Remarks
Pairs naturally with snapshot assertions. Render the pose once, then pin the result against a baseline:
var rendered = PoseRenderer.Render(position, orientation, tolerance: 1e-4);
await Assert.That(rendered).MatchesSnapshot();
The MatchesSnapshot() extension above lives in the sibling
SnapshotAssertions.TUnit package; this package does not depend on it. The
two-line composition is deliberate: it lets consumers reach for the renderer without
committing to a specific snapshot framework, and lets the SnapshotAssertions package
stay an opt-in pairing rather than a transitive dependency.
Orientation is rendered verbatim — the sign is not canonicalized. A quaternion
and its negation (q and -q) represent the same rotation but render
differently. That is intentional: pinning the raw components means a regression that
flips a quaternion sign surfaces as a snapshot diff. Callers asserting rotational
equivalence rather than component identity should use the IsRotationallyEquivalentTo
assertion instead of a rendered snapshot.
The tolerance is recorded, not applied. The renderer performs no comparison; it echoes the supplied tolerance into the output so the snapshot baseline records the asserted precision. A tolerance silently loosened during a refactor then surfaces as a snapshot diff.
Deterministic formatting. Components use the invariant-culture F6 fixed
format — six fractional digits, enough to distinguish typical calibration / pose
outputs without recording floating-point noise that would make the snapshot fragile
across platforms. The tolerance uses the invariant-culture G general format.
Lines are terminated with the literal LF byte ('\n'), never
NewLine, so a snapshot committed on one OS stays
byte-stable for test runs on every other.
Methods
Render(Quaternion, double)
Renders an orientation alone as a single quat: line.
public static string Render(Quaternion orientation, double tolerance)
Parameters
orientationQuaternionThe pose rotation, rendered verbatim (sign not canonicalized).
tolerancedoubleThe asserted tolerance, echoed into the line.
Returns
- string
A deterministic single-line, LF-terminated text rendering of the orientation.
Render(Vector3, double)
Renders a position alone as a single pos: line.
public static string Render(Vector3 position, double tolerance)
Parameters
positionVector3The pose translation (typically metres).
tolerancedoubleThe asserted tolerance, echoed into the line.
Returns
- string
A deterministic single-line, LF-terminated text rendering of the position.
Render(Vector3, Quaternion, double)
Renders a position and orientation pair as a two-line pose snapshot: a
pos: line followed by a quat: line.
public static string Render(Vector3 position, Quaternion orientation, double tolerance)
Parameters
positionVector3The pose translation (typically metres).
orientationQuaternionThe pose rotation, rendered verbatim (sign not canonicalized).
tolerancedoubleThe asserted tolerance, echoed into both lines.
Returns
- string
A deterministic two-line, LF-terminated text rendering of the pose.