Table of Contents

Struct FixedOrientedBox

Namespace
FixedMathSharp.Geometry
Assembly
FixedMathSharp.dll

Represents an immutable oriented box through canonical center, orientation, and positive local half-extents.

public readonly struct FixedOrientedBox : IEquatable<FixedOrientedBox>
Implements
Inherited Members

Remarks

World corners are intentionally not stored or exposed. Use local feature selection and TryMaterializeLocalPoint(Vector3d, out Vector3d) when a representable world-space witness is required. Geometry is evaluated against the exact scale-invariant rational basis of the stored quaternion; rounded axes are presentation values rather than query inputs.

Constructors

FixedOrientedBox(Vector3d, FixedQuaternion, Vector3d)

Initializes an oriented box from canonical geometry.

[JsonConstructor]
public FixedOrientedBox(Vector3d center, FixedQuaternion orientation, Vector3d halfExtents)

Parameters

center Vector3d
orientation FixedQuaternion
halfExtents Vector3d

Exceptions

ArgumentException

orientation is not normalized.

ArgumentOutOfRangeException

At least one half-extent is not positive.

Fields

CornerCount

The number of stable local corners exposed by GetLocalCorner(int).

public const int CornerCount = 8

Field Value

int

Properties

Center

The world-space center.

[JsonInclude]
public Vector3d Center { get; }

Property Value

Vector3d

HalfExtents

The positive local face distances.

[JsonInclude]
public Vector3d HalfExtents { get; }

Property Value

Vector3d

Orientation

The normalized local-to-world orientation.

[JsonInclude]
public FixedQuaternion Orientation { get; }

Property Value

FixedQuaternion

Methods

Contains(Vector3d)

Returns whether a world-space point lies inside or on every conceptual box face.

public bool Contains(Vector3d point)

Parameters

point Vector3d

Returns

bool

Equals(FixedOrientedBox)

public bool Equals(FixedOrientedBox other)

Parameters

other FixedOrientedBox

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetAxes(out Vector3d, out Vector3d, out Vector3d)

Gets the nearest round-half-to-even Fixed64 views of all three exact local-to-world axes.

public void GetAxes(out Vector3d axisX, out Vector3d axisY, out Vector3d axisZ)

Parameters

axisX Vector3d
axisY Vector3d
axisZ Vector3d

GetBoundsClippedToDomain()

Gets the least-outward analytical axis-aligned bounds, clipped only at the final representable scalar endpoints.

public FixedBoundBox GetBoundsClippedToDomain()

Returns

FixedBoundBox

GetCircleSlabSeparationLowerBound(Vector3d, Fixed64, Fixed64)

Returns a conservative X/Z separation lower bound between this box and a circle extruded through a fixed world-Y slab.

public Fixed64 GetCircleSlabSeparationLowerBound(Vector3d slabCenter, Fixed64 slabHalfThickness, Fixed64 radius)

Parameters

slabCenter Vector3d
slabHalfThickness Fixed64
radius Fixed64

Returns

Fixed64

Remarks

Projected edge witnesses are certified against every rational half-plane. When the closest feature is a projected vertex, the result uses the full-domain Euclidean distance floor before subtracting the circle radius. The result never overestimates true projected separation. When the Y intervals are disjoint, it returns the conservative vertical interval gap instead.

GetClosestPointAnchor(Vector3d)

Gets the conceptual closest surface point in this box's rigid frame.

public FixedPointAnchor GetClosestPointAnchor(Vector3d point)

Parameters

point Vector3d

Returns

FixedPointAnchor

Remarks

Outside points clamp independently to the local extents. Inside points select the nearest face with stable X, then Y, then Z ties. The returned anchor remains valid when the selected absolute world point is outside the representable scalar domain.

GetHashCode()

public override int GetHashCode()

Returns

int

GetLocalCorner(int)

Gets a stable center-relative local corner.

public Vector3d GetLocalCorner(int index)

Parameters

index int

Returns

Vector3d

Remarks

Index bits select positive X, Y, and Z respectively. The order is ---, +--, -+-, ++-, --+, +-+, -++, +++.

GetLocalSupportPoint(Vector3d)

Gets the center-relative local support point for a world-space direction.

public Vector3d GetLocalSupportPoint(Vector3d worldDirection)

Parameters

worldDirection Vector3d

Returns

Vector3d

Remarks

An exact zero projection selects the negative extent so ties retain the lower local corner index.

GetNearestFaceNormal(Vector3d)

Gets the nearest representable normal of the nearest conceptual face.

public Vector3d GetNearestFaceNormal(Vector3d point)

Parameters

point Vector3d

Returns

Vector3d

Remarks

Outside points select the first violated axis in X, then Y, then Z order, matching their nearest clamped surface feature. For contained points, equal inward face distances use the same axis order. A zero local projection selects the positive face.

TryGetCenteredCapsuleContact(Vector3d, FixedQuaternion, Vector3d, Fixed64, Fixed64, out FixedContactAnchors)

Attempts to construct an exact contact against a centered 3D capsule.

public bool TryGetCenteredCapsuleContact(Vector3d capsuleCenter, FixedQuaternion capsuleRotation, Vector3d localCapsuleAxisDirection, Fixed64 capsuleAxisLength, Fixed64 capsuleRadius, out FixedContactAnchors contact)

Parameters

capsuleCenter Vector3d
capsuleRotation FixedQuaternion
localCapsuleAxisDirection Vector3d
capsuleAxisLength Fixed64
capsuleRadius Fixed64
contact FixedContactAnchors

Returns

bool

TryGetCenteredCapsuleSlabContact(Vector3d, Fixed64, Vector2d, Fixed64, Fixed64, Fixed64, out FixedContactAnchors)

Attempts to construct an exact contact against a centered planar capsule extruded through a closed world-Y slab.

public bool TryGetCenteredCapsuleSlabContact(Vector3d slabCenter, Fixed64 capsuleFrameRotation, Vector2d localCapsuleAxisDirection, Fixed64 capsuleAxisLength, Fixed64 capsuleRadius, Fixed64 slabHalfThickness, out FixedContactAnchors contact)

Parameters

slabCenter Vector3d
capsuleFrameRotation Fixed64
localCapsuleAxisDirection Vector2d
capsuleAxisLength Fixed64
capsuleRadius Fixed64
slabHalfThickness Fixed64
contact FixedContactAnchors

Returns

bool

TryGetCenteredCylinderContact(Vector3d, FixedQuaternion, Vector3d, Fixed64, Fixed64, out FixedContactAnchors)

Attempts to construct an exact contact against a centered finite cylinder.

public bool TryGetCenteredCylinderContact(Vector3d cylinderCenter, FixedQuaternion cylinderRotation, Vector3d localCylinderAxisDirection, Fixed64 cylinderAxisLength, Fixed64 cylinderRadius, out FixedContactAnchors contact)

Parameters

cylinderCenter Vector3d
cylinderRotation FixedQuaternion
localCylinderAxisDirection Vector3d
cylinderAxisLength Fixed64
cylinderRadius Fixed64
contact FixedContactAnchors

Returns

bool

TryGetCenteredCylinderContact(Vector3d, FixedQuaternion, Vector3d, Fixed64, Fixed64, Span<FixedContactLocalPoints>, out FixedContactAnchors, out int)

Attempts to construct an exact contact against a centered finite cylinder and, for a parallel cap-to-face feature, clips a stable allocation-free contact set from the disk/rectangle intersection.

public bool TryGetCenteredCylinderContact(Vector3d cylinderCenter, FixedQuaternion cylinderRotation, Vector3d localCylinderAxisDirection, Fixed64 cylinderAxisLength, Fixed64 cylinderRadius, Span<FixedContactLocalPoints> capFaceContacts, out FixedContactAnchors contact, out int capFaceContactCount)

Parameters

cylinderCenter Vector3d
cylinderRotation FixedQuaternion
localCylinderAxisDirection Vector3d
cylinderAxisLength Fixed64
cylinderRadius Fixed64
capFaceContacts Span<FixedContactLocalPoints>
contact FixedContactAnchors
capFaceContactCount int

Returns

bool

Remarks

capFaceContacts must provide capacity for four contacts. contact always contains the primary exact contact relation when the shapes overlap. capFaceContactCount is zero for non-cap-face features, so callers should use the primary contact in that case.

TryGetCircleSlabContact(Vector3d, Fixed64, Fixed64, Fixed64, out FixedContactAnchors)

Attempts to construct an exact contact against a vertical circular prism centered in X/Z and extruded through a closed world-Y slab.

public bool TryGetCircleSlabContact(Vector3d slabCenter, Fixed64 circleFrameRotation, Fixed64 slabHalfThickness, Fixed64 radius, out FixedContactAnchors contact)

Parameters

slabCenter Vector3d
circleFrameRotation Fixed64
slabHalfThickness Fixed64
radius Fixed64
contact FixedContactAnchors

Returns

bool

TryGetCircleSlabSweepDistance(Vector3d, Vector2d, Fixed64, Fixed64, Fixed64, out Fixed64)

Finds the first X/Z travel distance at which a circle extruded through a fixed world-Y slab intersects this oriented box.

public bool TryGetCircleSlabSweepDistance(Vector3d slabStartCenter, Vector2d normalizedDirection, Fixed64 maxDistance, Fixed64 slabHalfThickness, Fixed64 radius, out Fixed64 distance)

Parameters

slabStartCenter Vector3d
normalizedDirection Vector2d
maxDistance Fixed64
slabHalfThickness Fixed64
radius Fixed64
distance Fixed64

Returns

bool

Remarks

The slab-clipped box projection remains an internal wide rational relation. No box corner, slab intersection, or projected polygon must be representable. Tangency and start overlap are inclusive, and the returned distance uses round-half-to-even.

TryGetClosestPointOnSurface(Vector3d, out Vector3d)

Attempts to materialize the nearest lattice representation of the conceptual closest surface point.

public bool TryGetClosestPointOnSurface(Vector3d point, out Vector3d closestPoint)

Parameters

point Vector3d
closestPoint Vector3d

Returns

bool

Remarks

Outside points clamp independently to the local extents. Inside points select the nearest face with stable X, then Y, then Z ties. The method returns false only when the selected final world point is not representable.

TryGetContact(FixedOrientedBox, out FixedContactAnchors)

Attempts to construct an exact contact against another oriented box.

public bool TryGetContact(FixedOrientedBox other, out FixedContactAnchors contact)

Parameters

other FixedOrientedBox
contact FixedContactAnchors

Returns

bool

TryGetConvexHullContact(Vector3d, FixedQuaternion, ReadOnlySpan<Vector3d>, ReadOnlySpan<int>, ReadOnlySpan<int>, out FixedContactAnchors)

Attempts to construct an exact contact against a convex point span.

public bool TryGetConvexHullContact(Vector3d hullOrigin, FixedQuaternion hullOrientation, ReadOnlySpan<Vector3d> hullLocalOffsets, ReadOnlySpan<int> triangleVertexIndices, ReadOnlySpan<int> edgeVertexPairs, out FixedContactAnchors contact)

Parameters

hullOrigin Vector3d
hullOrientation FixedQuaternion
hullLocalOffsets ReadOnlySpan<Vector3d>
triangleVertexIndices ReadOnlySpan<int>
edgeVertexPairs ReadOnlySpan<int>
contact FixedContactAnchors

Returns

bool

Remarks

Hull points are origin-relative offsets expressed in the hull's local orientation. Triangle and edge indices provide the complete convex SAT topology. The method performs no absolute world-point materialization.

TryGetConvexPrismContact(Vector3d, Fixed64, ReadOnlySpan<Vector2d>, Fixed64, out FixedContactAnchors)

Attempts to construct an exact contact against a rotated convex polygon extruded through a closed world-Y slab.

public bool TryGetConvexPrismContact(Vector3d prismOrigin, Fixed64 prismRotation, ReadOnlySpan<Vector2d> prismLocalOffsets, Fixed64 prismHalfThickness, out FixedContactAnchors contact)

Parameters

prismOrigin Vector3d

The representable prism origin.

prismRotation Fixed64

The prism's counterclockwise X/Z rotation in radians.

prismLocalOffsets ReadOnlySpan<Vector2d>

Ordered clockwise or counterclockwise X/Z boundary offsets in the prism's local frame.

prismHalfThickness Fixed64

The positive world-Y half-thickness.

contact FixedContactAnchors

The frame-relative contact anchors when overlapping.

Returns

bool

TryGetRayIntersectionInterval(FixedRay, Fixed64, out Fixed64, out Fixed64)

Finds the closed parameter interval where a bounded ray overlaps this oriented box.

public bool TryGetRayIntersectionInterval(FixedRay ray, Fixed64 maxParameter, out Fixed64 entry, out Fixed64 exit)

Parameters

ray FixedRay
maxParameter Fixed64
entry Fixed64
exit Fixed64

Returns

bool

Remarks

World-to-local projections and slab clipping retain the exact rational quaternion basis. The direction need not be normalized.

TryGetSphereContact(Vector3d, FixedQuaternion, Fixed64, out FixedContactAnchors)

Attempts to construct an exact box-to-sphere contact using only center-relative contact offsets.

public bool TryGetSphereContact(Vector3d sphereCenter, FixedQuaternion sphereRotation, Fixed64 sphereRadius, out FixedContactAnchors contact)

Parameters

sphereCenter Vector3d

The sphere center.

sphereRotation FixedQuaternion

The normalized rigid frame used to retain stable sphere-local contact feature identity.

sphereRadius Fixed64

The nonnegative sphere radius.

contact FixedContactAnchors

The relative contact relation when overlapping.

Returns

bool

true when the conceptual shapes overlap and both required relative offsets are representable.

TryGetSupportDifference(FixedOrientedBox, Vector3d, out Vector3d)

Attempts to construct the exact Minkowski support difference between this box and other.

public bool TryGetSupportDifference(FixedOrientedBox other, Vector3d worldDirection, out Vector3d difference)

Parameters

other FixedOrientedBox
worldDirection Vector3d
difference Vector3d

Returns

bool

Remarks

Both rotated support offsets and the center difference are retained as rational wide values until one final narrowing per component.

TryGetSupportDifference(Vector3d, Vector3d, Vector3d, out Vector3d)

Attempts to construct one exact-final-narrowing Minkowski support difference between this box and another origin-relative support.

public bool TryGetSupportDifference(Vector3d otherOrigin, Vector3d otherOriginSupportOffset, Vector3d worldDirection, out Vector3d difference)

Parameters

otherOrigin Vector3d
otherOriginSupportOffset Vector3d
worldDirection Vector3d
difference Vector3d

Returns

bool

Remarks

The result is (Center + boxSupport) - (otherOrigin + otherOriginSupportOffset). Neither absolute support point is materialized independently.

TryGetSupportOffset(Vector3d, out Vector3d)

Attempts to return the center-relative world-space support offset for a direction.

public bool TryGetSupportOffset(Vector3d worldDirection, out Vector3d centerOffset)

Parameters

worldDirection Vector3d
centerOffset Vector3d

Returns

bool

Remarks

Exact zero projections select the negative local extent so ties retain the stable lower corner index.

TryGetTriangleContact(Vector3d, FixedQuaternion, FixedTriangle, out FixedContactAnchors)

Attempts to construct an exact contact against a nondegenerate triangle.

public bool TryGetTriangleContact(Vector3d triangleOrigin, FixedQuaternion triangleRotation, FixedTriangle triangle, out FixedContactAnchors contact)

Parameters

triangleOrigin Vector3d

The triangle's rigid-frame origin.

triangleRotation FixedQuaternion

The triangle's local-to-world rotation.

triangle FixedTriangle

The triangle in its rigid-frame coordinates.

contact FixedContactAnchors

The box-center-relative and triangle-origin-relative contact relation.

Returns

bool

true when the shapes overlap and both relative contact anchors are representable; otherwise false.

TryGetTriangleContact(Vector3d, FixedQuaternion, FixedTriangle, Span<FixedContactLocalPoints>, out FixedContactAnchors, out int)

Attempts to construct an exact triangle contact and, for a parallel box-face/triangle-face feature, clips stable box corners to the triangle.

public bool TryGetTriangleContact(Vector3d triangleOrigin, FixedQuaternion triangleRotation, FixedTriangle triangle, Span<FixedContactLocalPoints> faceContacts, out FixedContactAnchors contact, out int faceContactCount)

Parameters

triangleOrigin Vector3d
triangleRotation FixedQuaternion
triangle FixedTriangle
faceContacts Span<FixedContactLocalPoints>
contact FixedContactAnchors
faceContactCount int

Returns

bool

Remarks

faceContacts must provide capacity for four contacts. contact always contains the primary exact contact relation when the shapes overlap. faceContactCount is zero for non-face features.

TryMaterializeLocalPoint(Vector3d, out Vector3d)

Attempts to materialize a center-relative local point in world space.

public bool TryMaterializeLocalPoint(Vector3d localPoint, out Vector3d worldPoint)

Parameters

localPoint Vector3d
worldPoint Vector3d

Returns

bool

Remarks

Each coordinate retains the exact rational quaternion basis, all three products, and the center contribution until one final round-half-to-even conversion. The result is the nearest lattice representation of the conceptual point; a conceptual boundary point need not remain exactly on that boundary after quantization. Failure is atomic.

TryTransformLocalOffset(Vector3d, out Vector3d)

Attempts to rotate a center-relative local offset into world-space coordinates without adding Center.

public bool TryTransformLocalOffset(Vector3d localOffset, out Vector3d worldOffset)

Parameters

localOffset Vector3d
worldOffset Vector3d

Returns

bool

Remarks

All three quaternion-basis products are retained until one final round-half-to-even conversion per component. This is the canonical admission path for relative box features whose absolute world points may lie outside the scalar coordinate domain.

Operators

operator ==(FixedOrientedBox, FixedOrientedBox)

Determines whether two boxes have identical canonical state.

public static bool operator ==(FixedOrientedBox left, FixedOrientedBox right)

Parameters

left FixedOrientedBox
right FixedOrientedBox

Returns

bool

operator !=(FixedOrientedBox, FixedOrientedBox)

Determines whether two boxes have different canonical state.

public static bool operator !=(FixedOrientedBox left, FixedOrientedBox right)

Parameters

left FixedOrientedBox
right FixedOrientedBox

Returns

bool