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
centerVector3dorientationFixedQuaternionhalfExtentsVector3d
Exceptions
- ArgumentException
orientationis 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
Properties
Center
The world-space center.
[JsonInclude]
public Vector3d Center { get; }
Property Value
HalfExtents
The positive local face distances.
[JsonInclude]
public Vector3d HalfExtents { get; }
Property Value
Orientation
The normalized local-to-world orientation.
[JsonInclude]
public FixedQuaternion Orientation { get; }
Property Value
Methods
Contains(Vector3d)
Returns whether a world-space point lies inside or on every conceptual box face.
public bool Contains(Vector3d point)
Parameters
pointVector3d
Returns
Equals(FixedOrientedBox)
public bool Equals(FixedOrientedBox other)
Parameters
otherFixedOrientedBox
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
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
GetBoundsClippedToDomain()
Gets the least-outward analytical axis-aligned bounds, clipped only at the final representable scalar endpoints.
public FixedBoundBox GetBoundsClippedToDomain()
Returns
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
Returns
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
pointVector3d
Returns
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
GetLocalCorner(int)
Gets a stable center-relative local corner.
public Vector3d GetLocalCorner(int index)
Parameters
indexint
Returns
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
worldDirectionVector3d
Returns
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
pointVector3d
Returns
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
capsuleCenterVector3dcapsuleRotationFixedQuaternionlocalCapsuleAxisDirectionVector3dcapsuleAxisLengthFixed64capsuleRadiusFixed64contactFixedContactAnchors
Returns
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
slabCenterVector3dcapsuleFrameRotationFixed64localCapsuleAxisDirectionVector2dcapsuleAxisLengthFixed64capsuleRadiusFixed64slabHalfThicknessFixed64contactFixedContactAnchors
Returns
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
cylinderCenterVector3dcylinderRotationFixedQuaternionlocalCylinderAxisDirectionVector3dcylinderAxisLengthFixed64cylinderRadiusFixed64contactFixedContactAnchors
Returns
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
cylinderCenterVector3dcylinderRotationFixedQuaternionlocalCylinderAxisDirectionVector3dcylinderAxisLengthFixed64cylinderRadiusFixed64capFaceContactsSpan<FixedContactLocalPoints>contactFixedContactAnchorscapFaceContactCountint
Returns
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
slabCenterVector3dcircleFrameRotationFixed64slabHalfThicknessFixed64radiusFixed64contactFixedContactAnchors
Returns
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
slabStartCenterVector3dnormalizedDirectionVector2dmaxDistanceFixed64slabHalfThicknessFixed64radiusFixed64distanceFixed64
Returns
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
Returns
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
otherFixedOrientedBoxcontactFixedContactAnchors
Returns
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
hullOriginVector3dhullOrientationFixedQuaternionhullLocalOffsetsReadOnlySpan<Vector3d>triangleVertexIndicesReadOnlySpan<int>edgeVertexPairsReadOnlySpan<int>contactFixedContactAnchors
Returns
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
prismOriginVector3dThe representable prism origin.
prismRotationFixed64The prism's counterclockwise X/Z rotation in radians.
prismLocalOffsetsReadOnlySpan<Vector2d>Ordered clockwise or counterclockwise X/Z boundary offsets in the prism's local frame.
prismHalfThicknessFixed64The positive world-Y half-thickness.
contactFixedContactAnchorsThe frame-relative contact anchors when overlapping.
Returns
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
Returns
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
sphereCenterVector3dThe sphere center.
sphereRotationFixedQuaternionThe normalized rigid frame used to retain stable sphere-local contact feature identity.
sphereRadiusFixed64The nonnegative sphere radius.
contactFixedContactAnchorsThe relative contact relation when overlapping.
Returns
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
otherFixedOrientedBoxworldDirectionVector3ddifferenceVector3d
Returns
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
Returns
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
Returns
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
triangleOriginVector3dThe triangle's rigid-frame origin.
triangleRotationFixedQuaternionThe triangle's local-to-world rotation.
triangleFixedTriangleThe triangle in its rigid-frame coordinates.
contactFixedContactAnchorsThe 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
triangleOriginVector3dtriangleRotationFixedQuaterniontriangleFixedTrianglefaceContactsSpan<FixedContactLocalPoints>contactFixedContactAnchorsfaceContactCountint
Returns
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
Returns
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
Returns
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
leftFixedOrientedBoxrightFixedOrientedBox
Returns
operator !=(FixedOrientedBox, FixedOrientedBox)
Determines whether two boxes have different canonical state.
public static bool operator !=(FixedOrientedBox left, FixedOrientedBox right)
Parameters
leftFixedOrientedBoxrightFixedOrientedBox