Skip to content

Commit 7d2ac67

Browse files
committed
feat(geometry): test swept upright cylinders against convex prisms
1 parent e400999 commit 7d2ac67

6 files changed

Lines changed: 1137 additions & 2 deletions

File tree

docs/wiki/bounds-and-geometry.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,13 @@ Choose the represented boundary carefully:
218218
This distinction is why the API exposes named sweep methods instead of treating
219219
every query as an expanded axis-aligned bound.
220220

221+
`FixedConvexPrismRelations.IntersectsSweptUprightCylinderStrict` answers the
222+
joint continuous relation between a translated upright cylinder and a rotated
223+
vertical convex prism. It keeps one exact parameter domain for both footprint
224+
and height overlap, so planar tangency, vertical tangency, and intervals that
225+
meet only at one boundary parameter do not become false positive volume
226+
intersections through independently rounded roots.
227+
221228
## Triangles and contacts
222229

223230
Triangles preserve vertex order. `FixedTriangle2d` exposes planar barycentric
@@ -277,6 +284,7 @@ physics-response API.
277284
| Swept sphere versus cylinder or box | `FixedSegment` |
278285
| Centered shape support, containment, or materialization | `FixedSegment2d`, `FixedSegment` static helpers |
279286
| Shape support inside a world-Y layer | `FixedSlabProjection` |
287+
| Swept upright cylinder versus a vertical convex prism | `FixedConvexPrismRelations` |
280288
| Triangle contacts or finite-shape relations | `FixedTriangle` |
281289
| Relative witnesses outside ordinary world-coordinate range | `FixedPointAnchor`, `FixedPointAnchor2d`, contact-anchor types |
282290

src/FixedMathSharp/Geometry/Primitives/Relations/FixedConvexPrismRelations.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,59 @@ namespace FixedMathSharp;
1616
/// </summary>
1717
public static class FixedConvexPrismRelations
1818
{
19+
/// <summary>
20+
/// Determines whether an upright cylinder translated between two
21+
/// bottom-center points has strict positive-volume overlap with a rotated
22+
/// vertical convex prism at any shared continuous parameter in [0, 1].
23+
/// </summary>
24+
/// <remarks>
25+
/// Planar tangency, vertical tangency, and contact that exists only where
26+
/// the planar and vertical strict intervals meet at one boundary parameter
27+
/// return <see langword="false"/>. A zero radius requires the swept axis
28+
/// point to enter the strict prism footprint. The joint parameter relation
29+
/// is evaluated with exact wide intermediates and does not publish rounded
30+
/// interval endpoints.
31+
/// </remarks>
32+
/// <param name="bottomStart">The cylinder bottom center at parameter zero.</param>
33+
/// <param name="bottomEnd">The cylinder bottom center at parameter one.</param>
34+
/// <param name="radius">The nonnegative cylinder radius.</param>
35+
/// <param name="height">The positive full cylinder height.</param>
36+
/// <param name="prismOrigin">The center of the vertical convex prism.</param>
37+
/// <param name="prismRotation">The prism footprint rotation about world Y.</param>
38+
/// <param name="prismLocalOffsets">At least three ordered convex-footprint offsets.</param>
39+
/// <param name="prismHalfThickness">The positive prism half-thickness along world Y.</param>
40+
/// <exception cref="ArgumentOutOfRangeException">
41+
/// <paramref name="radius"/> is negative, <paramref name="height"/> is not
42+
/// positive, or <paramref name="prismHalfThickness"/> is not positive.
43+
/// </exception>
44+
/// <exception cref="ArgumentException">
45+
/// Fewer than three ordered prism offsets were supplied.
46+
/// </exception>
47+
public static bool IntersectsSweptUprightCylinderStrict(
48+
Vector3d bottomStart,
49+
Vector3d bottomEnd,
50+
Fixed64 radius,
51+
Fixed64 height,
52+
Vector3d prismOrigin,
53+
Fixed64 prismRotation,
54+
ReadOnlySpan<Vector2d> prismLocalOffsets,
55+
Fixed64 prismHalfThickness)
56+
{
57+
if (height <= Fixed64.Zero)
58+
throw new ArgumentOutOfRangeException(nameof(height));
59+
ValidatePrism(radius, prismLocalOffsets, prismHalfThickness);
60+
return WideConvexPrismRelations
61+
.IntersectsSweptUprightCylinderStrict(
62+
bottomStart,
63+
bottomEnd,
64+
radius,
65+
height,
66+
prismOrigin,
67+
prismRotation,
68+
prismLocalOffsets,
69+
prismHalfThickness);
70+
}
71+
1972
/// <summary>
2073
/// Attempts to construct canonical contact anchors between a rigidly
2174
/// transformed triangle and a rotated vertical convex prism.

src/FixedMathSharp/Geometry/Wide/Convex/WideConvex2dRelations.ProjectionMath.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ private static void GetWorldPoint(
468468
secondRotatedY);
469469
}
470470

471-
private static void GetRotatedOffset(
471+
internal static void GetRotatedOffset(
472472
RotationFrame2d rotation,
473473
Vector2d localPoint,
474474
out Signed192 x,

src/FixedMathSharp/Geometry/Wide/Convex/WideConvex2dRelations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal WideAxis2d(Signed192 x, Signed192 y)
3333
new(WideArithmetic.Negate(value.X), WideArithmetic.Negate(value.Y));
3434
}
3535

36-
private readonly struct RotationFrame2d
36+
internal readonly struct RotationFrame2d
3737
{
3838
internal static readonly RotationFrame2d Identity = new(
3939
Signed192.One,

0 commit comments

Comments
 (0)