Class FixedConvex2dRelations
- Namespace
- FixedMathSharp.Geometry
- Assembly
- FixedMathSharp.dll
Provides exact relations for convex 2D shapes represented by canonical origins, scalar rotations, and local vertex offsets.
public static class FixedConvex2dRelations
- Inheritance
-
FixedConvex2dRelations
- Inherited Members
Methods
ContainsPoint(Vector2d, Vector2d, Fixed64, ReadOnlySpan<Vector2d>)
Returns whether a world-space point lies inside or on a rotated closed convex polygon represented by a frame and local vertex offsets.
public static bool ContainsPoint(Vector2d point, Vector2d convexOrigin, Fixed64 convexRotation, ReadOnlySpan<Vector2d> convexVertexOffsets)
Parameters
pointVector2dconvexOriginVector2dconvexRotationFixed64convexVertexOffsetsReadOnlySpan<Vector2d>
Returns
ContainsPoint(Vector2d, Vector2d, ReadOnlySpan<Vector2d>)
Returns whether a world-space point lies inside or on a closed convex polygon represented by an origin and origin-relative vertices.
public static bool ContainsPoint(Vector2d point, Vector2d convexOrigin, ReadOnlySpan<Vector2d> convexVertexOffsets)
Parameters
pointVector2dconvexOriginVector2dconvexVertexOffsetsReadOnlySpan<Vector2d>
Returns
GetClosestPointAnchor(Vector2d, Vector2d, Fixed64, ReadOnlySpan<Vector2d>)
Finds the closest point on a rotated polygon while retaining that point in the polygon's supplied local frame.
public static FixedPointAnchor2d GetClosestPointAnchor(Vector2d point, Vector2d convexOrigin, Fixed64 convexRotation, ReadOnlySpan<Vector2d> convexVertexOffsets)
Parameters
pointVector2dconvexOriginVector2dconvexRotationFixed64convexVertexOffsetsReadOnlySpan<Vector2d>
Returns
GetClosestPointOffset(Vector2d, Vector2d, ReadOnlySpan<Vector2d>)
Finds the polygon-relative closest point to a world-space point without materializing polygon vertices.
public static Vector2d GetClosestPointOffset(Vector2d point, Vector2d convexOrigin, ReadOnlySpan<Vector2d> convexVertexOffsets)
Parameters
pointVector2dconvexOriginVector2dconvexVertexOffsetsReadOnlySpan<Vector2d>
Returns
GetSupportAnchor(Vector2d, Fixed64, ReadOnlySpan<Vector2d>, Vector2d)
Returns the first local vertex with the greatest exact world-space projection along a direction.
public static FixedPointAnchor2d GetSupportAnchor(Vector2d convexOrigin, Fixed64 convexRotation, ReadOnlySpan<Vector2d> convexVertexOffsets, Vector2d direction)
Parameters
convexOriginVector2dconvexRotationFixed64convexVertexOffsetsReadOnlySpan<Vector2d>directionVector2d
Returns
GetSupportOffset(ReadOnlySpan<Vector2d>, Vector2d)
Returns the first authored polygon-relative vertex with the greatest exact projection along a direction.
public static Vector2d GetSupportOffset(ReadOnlySpan<Vector2d> convexVertexOffsets, Vector2d direction)
Parameters
convexVertexOffsetsReadOnlySpan<Vector2d>directionVector2d
Returns
IsStrictlyConvex(ReadOnlySpan<Vector2d>)
Returns whether boundary-ordered vertices form a strictly convex polygon in either winding direction.
public static bool IsStrictlyConvex(ReadOnlySpan<Vector2d> convexVertexOffsets)
Parameters
convexVertexOffsetsReadOnlySpan<Vector2d>
Returns
TryGetAreaAndCentroid(ReadOnlySpan<Vector2d>, out Fixed64, out Vector2d)
Attempts to derive the area and centroid of a boundary-ordered convex polygon without narrowing cross products or weighted-coordinate sums.
public static bool TryGetAreaAndCentroid(ReadOnlySpan<Vector2d> convexVertexOffsets, out Fixed64 area, out Vector2d centroid)
Parameters
convexVertexOffsetsReadOnlySpan<Vector2d>areaFixed64centroidVector2d
Returns
- bool
false only when the polygon has exact zero signed area or its final centroid is outside the scalar domain.
Remarks
Area is nonnegative and clamps to MaxValue when the conceptual value exceeds the scalar domain. The centroid uses one final round-half-to-even conversion per component.
TryGetCircleContact(Vector2d, Fixed64, Fixed64, Vector2d, Fixed64, ReadOnlySpan<Vector2d>, out FixedPointAnchor2d, out FixedPointAnchor2d, out Vector2d, out Fixed64, out bool)
Attempts to build a contact-anchor pair between a conceptual circle and a rotated closed convex polygon.
public static bool TryGetCircleContact(Vector2d circleCenter, Fixed64 circleRotation, Fixed64 circleRadius, Vector2d convexOrigin, Fixed64 convexRotation, ReadOnlySpan<Vector2d> convexVertexOffsets, out FixedPointAnchor2d circleContact, out FixedPointAnchor2d convexContact, out Vector2d normal, out Fixed64 depth, out bool depthIsClamped)
Parameters
circleCenterVector2dcircleRotationFixed64circleRadiusFixed64convexOriginVector2dconvexRotationFixed64convexVertexOffsetsReadOnlySpan<Vector2d>circleContactFixedPointAnchor2dconvexContactFixedPointAnchor2dnormalVector2ddepthFixed64depthIsClampedbool
Returns
Remarks
A circle's rotation does not change its geometry, but it defines the rigid local frame of the returned circle anchor.
TryGetConvexContacts(Vector2d, Fixed64, ReadOnlySpan<Vector2d>, Vector2d, Fixed64, ReadOnlySpan<Vector2d>, Span<FixedPointAnchor2d>, Span<FixedPointAnchor2d>, out int, out Vector2d, out Fixed64, out bool)
Attempts to build up to two local-frame contact-anchor pairs between two rotated closed convex polygons.
public static bool TryGetConvexContacts(Vector2d firstOrigin, Fixed64 firstRotation, ReadOnlySpan<Vector2d> firstVertexOffsets, Vector2d secondOrigin, Fixed64 secondRotation, ReadOnlySpan<Vector2d> secondVertexOffsets, Span<FixedPointAnchor2d> firstContacts, Span<FixedPointAnchor2d> secondContacts, out int contactCount, out Vector2d normal, out Fixed64 depth, out bool depthIsClamped)
Parameters
firstOriginVector2dfirstRotationFixed64firstVertexOffsetsReadOnlySpan<Vector2d>secondOriginVector2dsecondRotationFixed64secondVertexOffsetsReadOnlySpan<Vector2d>firstContactsSpan<FixedPointAnchor2d>secondContactsSpan<FixedPointAnchor2d>contactCountintnormalVector2ddepthFixed64depthIsClampedbool
Returns
TryGetSegmentFirstIntersectionDistance(Vector2d, Vector2d, Fixed64, Vector2d, Fixed64, ReadOnlySpan<Vector2d>, out Fixed64, out Vector2d, out FixedPointAnchor2d)
Finds the first distance where a finite directed segment reaches a rotated closed convex polygon.
public static bool TryGetSegmentFirstIntersectionDistance(Vector2d start, Vector2d direction, Fixed64 maximumDistance, Vector2d convexOrigin, Fixed64 convexRotation, ReadOnlySpan<Vector2d> convexVertexOffsets, out Fixed64 distance, out Vector2d normal, out FixedPointAnchor2d convexContact)
Parameters
startVector2ddirectionVector2dmaximumDistanceFixed64convexOriginVector2dconvexRotationFixed64convexVertexOffsetsReadOnlySpan<Vector2d>distanceFixed64normalVector2dconvexContactFixedPointAnchor2d
Returns
TryGetSegmentFirstIntersectionDistance(Vector2d, Vector2d, Fixed64, Vector2d, ReadOnlySpan<Vector2d>, out Fixed64, out Vector2d, out Vector2d)
Finds the first distance where a finite directed segment reaches a closed convex polygon.
public static bool TryGetSegmentFirstIntersectionDistance(Vector2d start, Vector2d direction, Fixed64 maximumDistance, Vector2d convexOrigin, ReadOnlySpan<Vector2d> convexVertexOffsets, out Fixed64 distance, out Vector2d normal, out Vector2d convexContactOffset)
Parameters
startVector2ddirectionVector2dmaximumDistanceFixed64convexOriginVector2dconvexVertexOffsetsReadOnlySpan<Vector2d>distanceFixed64normalVector2dconvexContactOffsetVector2d
Returns
TryGetSweptCenteredCapsuleFirstDistance(Vector2d, Fixed64, Fixed64, Fixed64, Vector2d, Fixed64, Vector2d, Fixed64, ReadOnlySpan<Vector2d>, out Fixed64, out Vector2d, out FixedPointAnchor2d)
Finds the first distance where a translated centered rotated capsule reaches a rotated closed convex polygon.
public static bool TryGetSweptCenteredCapsuleFirstDistance(Vector2d capsuleCenter, Fixed64 capsuleRotation, Fixed64 capsuleAxisLength, Fixed64 capsuleRadius, Vector2d direction, Fixed64 maximumDistance, Vector2d convexOrigin, Fixed64 convexRotation, ReadOnlySpan<Vector2d> convexVertexOffsets, out Fixed64 distance, out Vector2d normal, out FixedPointAnchor2d convexContact)
Parameters
capsuleCenterVector2dcapsuleRotationFixed64capsuleAxisLengthFixed64capsuleRadiusFixed64directionVector2dmaximumDistanceFixed64convexOriginVector2dconvexRotationFixed64convexVertexOffsetsReadOnlySpan<Vector2d>distanceFixed64normalVector2dconvexContactFixedPointAnchor2d
Returns
TryGetSweptCenteredCapsuleFirstDistance(Vector2d, Vector2d, Fixed64, Fixed64, Vector2d, Fixed64, Vector2d, Fixed64, ReadOnlySpan<Vector2d>, out Fixed64, out Vector2d, out FixedPointAnchor2d)
Finds the first distance where a translated conceptual centered capsule reaches a rotated closed convex polygon.
public static bool TryGetSweptCenteredCapsuleFirstDistance(Vector2d capsuleCenter, Vector2d capsuleAxisDirection, Fixed64 capsuleAxisLength, Fixed64 capsuleRadius, Vector2d direction, Fixed64 maximumDistance, Vector2d convexOrigin, Fixed64 convexRotation, ReadOnlySpan<Vector2d> convexVertexOffsets, out Fixed64 distance, out Vector2d normal, out FixedPointAnchor2d convexContact)
Parameters
capsuleCenterVector2dcapsuleAxisDirectionVector2dcapsuleAxisLengthFixed64capsuleRadiusFixed64directionVector2dmaximumDistanceFixed64convexOriginVector2dconvexRotationFixed64convexVertexOffsetsReadOnlySpan<Vector2d>distanceFixed64normalVector2dconvexContactFixedPointAnchor2d
Returns
TryGetSweptCenteredCapsuleFirstDistance(Vector2d, Vector2d, Fixed64, Fixed64, Vector2d, Fixed64, Vector2d, ReadOnlySpan<Vector2d>, out Fixed64, out Vector2d, out Vector2d)
Finds the first distance where a translated conceptual centered capsule reaches a closed convex polygon.
public static bool TryGetSweptCenteredCapsuleFirstDistance(Vector2d capsuleCenter, Vector2d capsuleAxisDirection, Fixed64 capsuleAxisLength, Fixed64 capsuleRadius, Vector2d direction, Fixed64 maximumDistance, Vector2d convexOrigin, ReadOnlySpan<Vector2d> convexVertexOffsets, out Fixed64 distance, out Vector2d normal, out Vector2d convexContactOffset)
Parameters
capsuleCenterVector2dcapsuleAxisDirectionVector2dcapsuleAxisLengthFixed64capsuleRadiusFixed64directionVector2dmaximumDistanceFixed64convexOriginVector2dconvexVertexOffsetsReadOnlySpan<Vector2d>distanceFixed64normalVector2dconvexContactOffsetVector2d
Returns
TryGetSweptCircleFirstDistance(Vector2d, Fixed64, Vector2d, Fixed64, Vector2d, Fixed64, ReadOnlySpan<Vector2d>, out Fixed64, out Vector2d, out FixedPointAnchor2d)
Finds the first distance where a translated conceptual circle reaches a rotated closed convex polygon.
public static bool TryGetSweptCircleFirstDistance(Vector2d circleCenter, Fixed64 circleRadius, Vector2d direction, Fixed64 maximumDistance, Vector2d convexOrigin, Fixed64 convexRotation, ReadOnlySpan<Vector2d> convexVertexOffsets, out Fixed64 distance, out Vector2d normal, out FixedPointAnchor2d convexContact)
Parameters
circleCenterVector2dcircleRadiusFixed64directionVector2dmaximumDistanceFixed64convexOriginVector2dconvexRotationFixed64convexVertexOffsetsReadOnlySpan<Vector2d>distanceFixed64normalVector2dconvexContactFixedPointAnchor2d
Returns
TryGetSweptCircleFirstDistance(Vector2d, Fixed64, Vector2d, Fixed64, Vector2d, ReadOnlySpan<Vector2d>, out Fixed64, out Vector2d, out Vector2d)
Finds the first distance where a translated conceptual circle reaches a closed convex polygon.
public static bool TryGetSweptCircleFirstDistance(Vector2d circleCenter, Fixed64 circleRadius, Vector2d direction, Fixed64 maximumDistance, Vector2d convexOrigin, ReadOnlySpan<Vector2d> convexVertexOffsets, out Fixed64 distance, out Vector2d normal, out Vector2d convexContactOffset)
Parameters
circleCenterVector2dcircleRadiusFixed64directionVector2dmaximumDistanceFixed64convexOriginVector2dconvexVertexOffsetsReadOnlySpan<Vector2d>distanceFixed64normalVector2dconvexContactOffsetVector2d
Returns
TryGetSweptConvexFirstDistance(Vector2d, Fixed64, ReadOnlySpan<Vector2d>, Vector2d, Fixed64, Vector2d, Fixed64, ReadOnlySpan<Vector2d>, out Fixed64, out Vector2d, out FixedPointAnchor2d)
Finds the first distance where a translated rotated convex polygon reaches another rotated closed convex polygon.
public static bool TryGetSweptConvexFirstDistance(Vector2d moverOrigin, Fixed64 moverRotation, ReadOnlySpan<Vector2d> moverVertexOffsets, Vector2d direction, Fixed64 maximumDistance, Vector2d targetOrigin, Fixed64 targetRotation, ReadOnlySpan<Vector2d> targetVertexOffsets, out Fixed64 distance, out Vector2d normal, out FixedPointAnchor2d targetContact)
Parameters
moverOriginVector2dmoverRotationFixed64moverVertexOffsetsReadOnlySpan<Vector2d>directionVector2dmaximumDistanceFixed64targetOriginVector2dtargetRotationFixed64targetVertexOffsetsReadOnlySpan<Vector2d>distanceFixed64normalVector2dtargetContactFixedPointAnchor2d
Returns
TryGetSweptConvexFirstDistance(Vector2d, ReadOnlySpan<Vector2d>, Vector2d, Fixed64, Vector2d, ReadOnlySpan<Vector2d>, out Fixed64, out Vector2d, out Vector2d)
Finds the first distance where a translated closed convex polygon reaches another closed convex polygon.
public static bool TryGetSweptConvexFirstDistance(Vector2d moverOrigin, ReadOnlySpan<Vector2d> moverVertexOffsets, Vector2d direction, Fixed64 maximumDistance, Vector2d targetOrigin, ReadOnlySpan<Vector2d> targetVertexOffsets, out Fixed64 distance, out Vector2d normal, out Vector2d targetContactOffset)
Parameters
moverOriginVector2dmoverVertexOffsetsReadOnlySpan<Vector2d>directionVector2dmaximumDistanceFixed64targetOriginVector2dtargetVertexOffsetsReadOnlySpan<Vector2d>distanceFixed64normalVector2dtargetContactOffsetVector2d