Table of Contents

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

point Vector2d
convexOrigin Vector2d
convexRotation Fixed64
convexVertexOffsets ReadOnlySpan<Vector2d>

Returns

bool

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

point Vector2d
convexOrigin Vector2d
convexVertexOffsets ReadOnlySpan<Vector2d>

Returns

bool

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

point Vector2d
convexOrigin Vector2d
convexRotation Fixed64
convexVertexOffsets ReadOnlySpan<Vector2d>

Returns

FixedPointAnchor2d

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

point Vector2d
convexOrigin Vector2d
convexVertexOffsets ReadOnlySpan<Vector2d>

Returns

Vector2d

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

convexOrigin Vector2d
convexRotation Fixed64
convexVertexOffsets ReadOnlySpan<Vector2d>
direction Vector2d

Returns

FixedPointAnchor2d

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

convexVertexOffsets ReadOnlySpan<Vector2d>
direction Vector2d

Returns

Vector2d

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

convexVertexOffsets ReadOnlySpan<Vector2d>

Returns

bool

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

convexVertexOffsets ReadOnlySpan<Vector2d>
area Fixed64
centroid Vector2d

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

circleCenter Vector2d
circleRotation Fixed64
circleRadius Fixed64
convexOrigin Vector2d
convexRotation Fixed64
convexVertexOffsets ReadOnlySpan<Vector2d>
circleContact FixedPointAnchor2d
convexContact FixedPointAnchor2d
normal Vector2d
depth Fixed64
depthIsClamped bool

Returns

bool

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

firstOrigin Vector2d
firstRotation Fixed64
firstVertexOffsets ReadOnlySpan<Vector2d>
secondOrigin Vector2d
secondRotation Fixed64
secondVertexOffsets ReadOnlySpan<Vector2d>
firstContacts Span<FixedPointAnchor2d>
secondContacts Span<FixedPointAnchor2d>
contactCount int
normal Vector2d
depth Fixed64
depthIsClamped bool

Returns

bool

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

start Vector2d
direction Vector2d
maximumDistance Fixed64
convexOrigin Vector2d
convexRotation Fixed64
convexVertexOffsets ReadOnlySpan<Vector2d>
distance Fixed64
normal Vector2d
convexContact FixedPointAnchor2d

Returns

bool

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

start Vector2d
direction Vector2d
maximumDistance Fixed64
convexOrigin Vector2d
convexVertexOffsets ReadOnlySpan<Vector2d>
distance Fixed64
normal Vector2d
convexContactOffset Vector2d

Returns

bool

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

capsuleCenter Vector2d
capsuleRotation Fixed64
capsuleAxisLength Fixed64
capsuleRadius Fixed64
direction Vector2d
maximumDistance Fixed64
convexOrigin Vector2d
convexRotation Fixed64
convexVertexOffsets ReadOnlySpan<Vector2d>
distance Fixed64
normal Vector2d
convexContact FixedPointAnchor2d

Returns

bool

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

capsuleCenter Vector2d
capsuleAxisDirection Vector2d
capsuleAxisLength Fixed64
capsuleRadius Fixed64
direction Vector2d
maximumDistance Fixed64
convexOrigin Vector2d
convexRotation Fixed64
convexVertexOffsets ReadOnlySpan<Vector2d>
distance Fixed64
normal Vector2d
convexContact FixedPointAnchor2d

Returns

bool

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

capsuleCenter Vector2d
capsuleAxisDirection Vector2d
capsuleAxisLength Fixed64
capsuleRadius Fixed64
direction Vector2d
maximumDistance Fixed64
convexOrigin Vector2d
convexVertexOffsets ReadOnlySpan<Vector2d>
distance Fixed64
normal Vector2d
convexContactOffset Vector2d

Returns

bool

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

circleCenter Vector2d
circleRadius Fixed64
direction Vector2d
maximumDistance Fixed64
convexOrigin Vector2d
convexRotation Fixed64
convexVertexOffsets ReadOnlySpan<Vector2d>
distance Fixed64
normal Vector2d
convexContact FixedPointAnchor2d

Returns

bool

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

circleCenter Vector2d
circleRadius Fixed64
direction Vector2d
maximumDistance Fixed64
convexOrigin Vector2d
convexVertexOffsets ReadOnlySpan<Vector2d>
distance Fixed64
normal Vector2d
convexContactOffset Vector2d

Returns

bool

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

moverOrigin Vector2d
moverRotation Fixed64
moverVertexOffsets ReadOnlySpan<Vector2d>
direction Vector2d
maximumDistance Fixed64
targetOrigin Vector2d
targetRotation Fixed64
targetVertexOffsets ReadOnlySpan<Vector2d>
distance Fixed64
normal Vector2d
targetContact FixedPointAnchor2d

Returns

bool

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

moverOrigin Vector2d
moverVertexOffsets ReadOnlySpan<Vector2d>
direction Vector2d
maximumDistance Fixed64
targetOrigin Vector2d
targetVertexOffsets ReadOnlySpan<Vector2d>
distance Fixed64
normal Vector2d
targetContactOffset Vector2d

Returns

bool