Table of Contents

Class Containment

Namespace
MathAssertions.Geometry3D
Assembly
MathAssertions.dll

Containment predicates: which primitives lie wholly inside which others. Implemented as extension methods so call sites read naturally (box.Contains(point), sphere.Contains(point)).

public static class Containment
Inheritance
Containment
Inherited Members

Methods

Contains(AxisAlignedBox, AxisAlignedBox)

Returns true when inner lies wholly inside outer (a box contains another box iff it contains the inner box's two extreme corners; AABBs are convex, so the two-corner test suffices).

public static bool Contains(this AxisAlignedBox outer, AxisAlignedBox inner)

Parameters

outer AxisAlignedBox

Outer box.

inner AxisAlignedBox

Inner box to test for containment.

Returns

bool

true if outer contains both corners of inner.

Contains(AxisAlignedBox, Sphere)

Returns true when sphere lies wholly inside box: the sphere center is at least one radius from every box face. Negative radii are accepted (the predicate becomes a "shrunken-box-contains- center" check); callers are responsible for using positive radii.

public static bool Contains(this AxisAlignedBox box, Sphere sphere)

Parameters

box AxisAlignedBox

Outer axis-aligned box.

sphere Sphere

Inner sphere to test.

Returns

bool

true if every face of box is at least sphere.Radius away from sphere's center.

Contains(AxisAlignedBox, Vector3)

Returns true when point lies inside the closed box defined by box (boundary included).

public static bool Contains(this AxisAlignedBox box, Vector3 point)

Parameters

box AxisAlignedBox

Axis-aligned box to test against.

point Vector3

Point to test.

Returns

bool

true if every component of point lies in the corresponding [Min, Max] interval.

Contains(OrientedBox, Vector3)

Returns true when point lies inside the closed oriented box. The point is rotated into the box's local frame by the inverse orientation, then a half-extent test is applied component-wise.

public static bool Contains(this OrientedBox box, Vector3 point)

Parameters

box OrientedBox

Oriented box to test against.

point Vector3

Point to test.

Returns

bool

true if the local-frame coordinates of point all lie within the box's half-extents.

Contains(Sphere, Vector3)

Returns true when point lies inside or on the boundary of sphere. Compared via squared distance so no square root is computed.

public static bool Contains(this Sphere sphere, Vector3 point)

Parameters

sphere Sphere

Sphere to test against.

point Vector3

Point to test.

Returns

bool

true if |point - center|^2 <= radius^2.

ConvexHullContains(ReadOnlySpan<Vector3>, Vector3, double)

Returns true when point lies inside the convex hull described by hullVertices, an array of triangulation-ready triples: every three consecutive vertices form one face triangle. Each triangle must be wound counter-clockwise when viewed from outside the hull so that the cross-product face normal points outward; a point is inside the hull iff its perpendicular distance onto the outward side of every face plane stays within tolerance.

public static bool ConvexHullContains(ReadOnlySpan<Vector3> hullVertices, Vector3 point, double tolerance)

Parameters

hullVertices ReadOnlySpan<Vector3>

Convex-hull face vertices in flat triples-of-three order; each triple is one CCW-outward face triangle.

point Vector3

Point to test.

tolerance double

Maximum allowed signed perpendicular distance onto the positive (outward) side of any face plane. Must be non-negative and not NaN.

Returns

bool

true if point is inside the hull within tolerance.

Remarks

0.1.0 implementation: tests half-space inclusion against each computed face triangle. Hulls supplied with arbitrary winding produce undefined containment. Automatic triangulation from a point cloud is deferred to 0.2.0.

The half-space deviation is normalized by the face normal's length before being compared to tolerance: the unnormalized cross-product magnitude is twice the face triangle's area, so comparing it directly to a length-dimensioned tolerance would let a re-triangulation of the same convex hull (subdividing a face into smaller triangles) shift the verdict for the same geometric point. Dividing by |normal| recovers the dimensionally correct signed distance from the face plane. Degenerate (zero-area) face triangles are skipped so they cannot produce a NaN signed distance from the division.

Spans whose length is not a positive multiple of three return false: the input is malformed and no half-space test is well-defined. The empty span returns false (no interior).

Exceptions

ArgumentOutOfRangeException

tolerance is NaN or negative.