Table of Contents

Class Geometry3DAssertions

Namespace
MathAssertions.TUnit
Assembly
MathAssertions.TUnit.dll

Fluent assertions over the MathAssertions.Geometry3D primitives: triangle / point-set property predicates, containment, closest-point distance, intersection, and pointcloud aggregates.

public static class Geometry3DAssertions
Inheritance
Geometry3DAssertions
Inherited Members

Remarks

Distance-from helpers call the static Distance form rather than the extension-method form because TUnit's [GenerateAssertion] source generator inlines expression bodies into a generated assertion class without copying the using directives that would be needed to resolve the extension call.

Methods

AreCoplanar(Vector3[], double)

Asserts every point in the array lies on a single plane within tolerance.

[GenerateAssertion(ExpectationMessage = "to be coplanar within tolerance {tolerance}", InlineMethodBody = false)]
public static bool AreCoplanar(this Vector3[] value, double tolerance)

Parameters

value Vector3[]
tolerance double

Returns

bool

ContainsBox(AxisAlignedBox, AxisAlignedBox)

Asserts the outer box contains inner.

[GenerateAssertion(ExpectationMessage = "to contain box {inner}", InlineMethodBody = true)]
public static bool ContainsBox(this AxisAlignedBox value, AxisAlignedBox inner)

Parameters

value AxisAlignedBox
inner AxisAlignedBox

Returns

bool

ContainsPoint(AxisAlignedBox, Vector3)

Asserts the AABB contains point.

[GenerateAssertion(ExpectationMessage = "to contain point {point}", InlineMethodBody = true)]
public static bool ContainsPoint(this AxisAlignedBox value, Vector3 point)

Parameters

value AxisAlignedBox
point Vector3

Returns

bool

ContainsPoint(OrientedBox, Vector3)

Asserts the oriented box contains point.

[GenerateAssertion(ExpectationMessage = "to contain point {point}", InlineMethodBody = true)]
public static bool ContainsPoint(this OrientedBox value, Vector3 point)

Parameters

value OrientedBox
point Vector3

Returns

bool

ContainsPoint(Sphere, Vector3)

Asserts the sphere contains point.

[GenerateAssertion(ExpectationMessage = "to contain point {point}", InlineMethodBody = true)]
public static bool ContainsPoint(this Sphere value, Vector3 point)

Parameters

value Sphere
point Vector3

Returns

bool

ContainsSphere(AxisAlignedBox, Sphere)

Asserts the box contains sphere entirely.

[GenerateAssertion(ExpectationMessage = "to contain sphere {sphere}", InlineMethodBody = true)]
public static bool ContainsSphere(this AxisAlignedBox value, Sphere sphere)

Parameters

value AxisAlignedBox
sphere Sphere

Returns

bool

ConvexHullContainsPoint(Vector3[], Vector3, double)

Asserts point lies inside the convex hull described by value's flat triples-of-three vertex layout.

[GenerateAssertion(ExpectationMessage = "to contain point {point} within tolerance {tolerance}", InlineMethodBody = false)]
public static bool ConvexHullContainsPoint(this Vector3[] value, Vector3 point, double tolerance)

Parameters

value Vector3[]
point Vector3
tolerance double

Returns

bool

HasCentroidAt(Vector3[], Vector3, double)

Asserts the cloud's centroid is approximately expected.

[GenerateAssertion(ExpectationMessage = "to have centroid approximately {expected} within tolerance {tolerance}", InlineMethodBody = false)]
public static bool HasCentroidAt(this Vector3[] value, Vector3 expected, double tolerance)

Parameters

value Vector3[]
expected Vector3
tolerance double

Returns

bool

HasDistanceFromPlane(Vector3, Plane, double, double)

Asserts the perpendicular distance from value to plane is approximately expected.

[GenerateAssertion(ExpectationMessage = "to be at distance {expected} from {plane} within tolerance {tolerance}", InlineMethodBody = true)]
public static bool HasDistanceFromPlane(this Vector3 value, Plane plane, double expected, double tolerance)

Parameters

value Vector3
plane Plane
expected double
tolerance double

Returns

bool

HasDistanceFromSegment(Vector3, LineSegment3D, double, double)

Asserts the closest-point distance from value to segment is approximately expected.

[GenerateAssertion(ExpectationMessage = "to be at distance {expected} from {segment} within tolerance {tolerance}", InlineMethodBody = true)]
public static bool HasDistanceFromSegment(this Vector3 value, LineSegment3D segment, double expected, double tolerance)

Parameters

value Vector3
segment LineSegment3D
expected double
tolerance double

Returns

bool

HasDistanceFromTriangle(Vector3, Triangle3D, double, double)

Asserts the closest-point distance from value to triangle is approximately expected.

[GenerateAssertion(ExpectationMessage = "to be at distance {expected} from {triangle} within tolerance {tolerance}", InlineMethodBody = true)]
public static bool HasDistanceFromTriangle(this Vector3 value, Triangle3D triangle, double expected, double tolerance)

Parameters

value Vector3
triangle Triangle3D
expected double
tolerance double

Returns

bool

IntersectsBox(AxisAlignedBox, AxisAlignedBox)

Asserts two boxes intersect (boundary contact counts).

[GenerateAssertion(ExpectationMessage = "to intersect box {other}", InlineMethodBody = true)]
public static bool IntersectsBox(this AxisAlignedBox value, AxisAlignedBox other)

Parameters

value AxisAlignedBox
other AxisAlignedBox

Returns

bool

IntersectsBox(Ray3D, AxisAlignedBox)

Asserts the ray hits box.

[GenerateAssertion(ExpectationMessage = "to intersect box {box}", InlineMethodBody = true)]
public static bool IntersectsBox(this Ray3D value, AxisAlignedBox box)

Parameters

value Ray3D
box AxisAlignedBox

Returns

bool

IntersectsPlane(Ray3D, Plane)

Asserts the ray hits plane in front of its origin.

[GenerateAssertion(ExpectationMessage = "to intersect plane {plane}", InlineMethodBody = true)]
public static bool IntersectsPlane(this Ray3D value, Plane plane)

Parameters

value Ray3D
plane Plane

Returns

bool

IntersectsSphere(Ray3D, Sphere)

Asserts the ray hits sphere.

[GenerateAssertion(ExpectationMessage = "to intersect sphere {sphere}", InlineMethodBody = true)]
public static bool IntersectsSphere(this Ray3D value, Sphere sphere)

Parameters

value Ray3D
sphere Sphere

Returns

bool

IntersectsSphere(Sphere, Sphere)

Asserts two spheres intersect (boundary contact counts).

[GenerateAssertion(ExpectationMessage = "to intersect sphere {other}", InlineMethodBody = true)]
public static bool IntersectsSphere(this Sphere value, Sphere other)

Parameters

value Sphere
other Sphere

Returns

bool

IntersectsTriangle(Ray3D, Triangle3D)

Asserts the ray hits triangle.

[GenerateAssertion(ExpectationMessage = "to intersect triangle {triangle}", InlineMethodBody = true)]
public static bool IntersectsTriangle(this Ray3D value, Triangle3D triangle)

Parameters

value Ray3D
triangle Triangle3D

Returns

bool

IsApproximatelyOnPlane(Vector3[], Plane, double)

Asserts every point in the cloud lies within maxResidual of plane.

[GenerateAssertion(ExpectationMessage = "to lie approximately on plane {plane} within residual {maxResidual}", InlineMethodBody = false)]
public static bool IsApproximatelyOnPlane(this Vector3[] value, Plane plane, double maxResidual)

Parameters

value Vector3[]
plane Plane
maxResidual double

Returns

bool

IsApproximatelyOnSphere(Vector3[], Vector3, float, double)

Asserts every point in the cloud lies within maxResidual of the sphere surface.

[GenerateAssertion(ExpectationMessage = "to lie approximately on a sphere centered at {center} with radius {radius} within residual {maxResidual}", InlineMethodBody = false)]
public static bool IsApproximatelyOnSphere(this Vector3[] value, Vector3 center, float radius, double maxResidual)

Parameters

value Vector3[]
center Vector3
radius float
maxResidual double

Returns

bool

IsBoundedByBox(Vector3[], AxisAlignedBox)

Asserts every point in the cloud lies inside box.

[GenerateAssertion(ExpectationMessage = "to be bounded by box {box}", InlineMethodBody = false)]
public static bool IsBoundedByBox(this Vector3[] value, AxisAlignedBox box)

Parameters

value Vector3[]
box AxisAlignedBox

Returns

bool

IsBoundedBySphere(Vector3[], Sphere)

Asserts every point in the cloud lies inside sphere.

[GenerateAssertion(ExpectationMessage = "to be bounded by sphere {sphere}", InlineMethodBody = false)]
public static bool IsBoundedBySphere(this Vector3[] value, Sphere sphere)

Parameters

value Vector3[]
sphere Sphere

Returns

bool

IsCollinear(Vector3[], double)

Asserts every point in the array is collinear within tolerance.

[GenerateAssertion(ExpectationMessage = "to be collinear within tolerance {tolerance}", InlineMethodBody = false)]
public static bool IsCollinear(this Vector3[] value, double tolerance)

Parameters

value Vector3[]
tolerance double

Returns

bool

IsDegenerate(Triangle3D, double)

Asserts the triangle's area is at most tolerance.

[GenerateAssertion(ExpectationMessage = "to be a degenerate triangle within tolerance {tolerance}", InlineMethodBody = true)]
public static bool IsDegenerate(this Triangle3D value, double tolerance)

Parameters

value Triangle3D
tolerance double

Returns

bool