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
outerAxisAlignedBoxOuter box.
innerAxisAlignedBoxInner box to test for containment.
Returns
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
boxAxisAlignedBoxOuter axis-aligned box.
sphereSphereInner sphere to test.
Returns
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
boxAxisAlignedBoxAxis-aligned box to test against.
pointVector3Point to test.
Returns
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
boxOrientedBoxOriented box to test against.
pointVector3Point to test.
Returns
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
Returns
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
hullVerticesReadOnlySpan<Vector3>Convex-hull face vertices in flat triples-of-three order; each triple is one CCW-outward face triangle.
pointVector3Point to test.
tolerancedoubleMaximum allowed signed perpendicular distance onto the positive (outward) side of any face plane. Must be non-negative and not NaN.
Returns
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
toleranceis NaN or negative.