Class ShapeHelper
Provides helper methods for calculating the properties of implicitly defined shapes.
public static class ShapeHelper
- Inheritance
-
ShapeHelper
- Inherited Members
Methods
CalculateBoundingBox<TSupport>(in TSupport, in JQuaternion, in JVector, out JBoundingBox)
Calculates the axis-aligned bounding box of a shape given its orientation and position.
public static void CalculateBoundingBox<TSupport>(in TSupport support, in JQuaternion orientation, in JVector position, out JBoundingBox box) where TSupport : ISupportMappable
Parameters
supportTSupportThe support map interface implemented by the shape.
orientationJQuaternionThe orientation of the shape.
positionJVectorThe position of the shape.
boxJBoundingBoxThe resulting bounding box.
Type Parameters
TSupport
CalculateMassInertia<TSupport>(in TSupport, out JMatrix, out JVector, out float, int)
Calculates the mass properties of an implicitly defined shape, assuming unit mass density.
public static void CalculateMassInertia<TSupport>(in TSupport support, out JMatrix inertia, out JVector centerOfMass, out float mass, int subdivisions = 4) where TSupport : ISupportMappable
Parameters
supportTSupportThe support map interface implemented by the shape.
inertiaJMatrixOutput parameter for the inertia tensor calculated relative to the Origin (0,0,0).
centerOfMassJVectorOutput parameter for the calculated center of mass vector (relative to the Origin).
massfloatOutput parameter for the calculated mass (Volume * density 1.0).
subdivisionsintThe recursion depth for the surface tessellation (default 4).
Type Parameters
TSupport
Remarks
The shape is approximated via surface tessellation using the specified number of subdivisions.
Note on Reference Frame:
The calculated inertia tensor is expressed relative to the coordinate system origin (0,0,0),
not the calculated centerOfMass.
MakeHull(IEnumerable<JVector>, int)
[Obsolete("Use Tessellate instead.")]
public static List<JTriangle> MakeHull(IEnumerable<JVector> vertices, int subdivisions = 3)
Parameters
verticesIEnumerable<JVector>subdivisionsint
Returns
MakeHull(ReadOnlySpan<JVector>, int)
[Obsolete("Use Tessellate instead.")]
public static List<JTriangle> MakeHull(ReadOnlySpan<JVector> vertices, int subdivisions = 3)
Parameters
verticesReadOnlySpan<JVector>subdivisionsint
Returns
MakeHull<TSupport>(in TSupport, int)
[Obsolete("Use Tessellate instead.")]
public static List<JTriangle> MakeHull<TSupport>(in TSupport support, int subdivisions = 3) where TSupport : ISupportMappable
Parameters
supportTSupportsubdivisionsint
Returns
Type Parameters
TSupport
MakeHull<TSupport, TCollection>(in TSupport, TCollection, int)
[Obsolete("Use Tessellate instead.")]
public static void MakeHull<TSupport, TCollection>(in TSupport support, TCollection hullCollection, int subdivisions = 3) where TSupport : ISupportMappable where TCollection : class, ICollection<JTriangle>
Parameters
supportTSupporthullCollectionTCollectionsubdivisionsint
Type Parameters
TSupportTCollection
SampleHull(IEnumerable<JVector>, int)
Approximates the convex hull of a given set of 3D vertices by sampling support points generated through recursive subdivision of an icosahedron.
public static List<JVector> SampleHull(IEnumerable<JVector> vertices, int subdivisions = 3)
Parameters
verticesIEnumerable<JVector>The vertices used to approximate the hull.
subdivisionsintThe number of recursive subdivisions applied to each icosahedron triangle. Higher values produce more sampling directions and better coverage, but increase computation. Default is 3.
Returns
- List<JVector>
A list of JVector points on the convex hull, sampled using directional support mapping from a refined spherical distribution.
Remarks
This method begins with a regular icosahedron and recursively subdivides each triangular face into smaller triangles, projecting new vertices onto the unit sphere. Each final vertex direction is passed to the support mapper to generate a hull point. The time complexity is O(4^n), where n is the number of subdivisions.
SampleHull(ReadOnlySpan<JVector>, int)
Approximates the convex hull of a given set of 3D vertices by sampling support points generated through recursive subdivision of an icosahedron.
public static List<JVector> SampleHull(ReadOnlySpan<JVector> vertices, int subdivisions = 3)
Parameters
verticesReadOnlySpan<JVector>The vertices used to approximate the hull.
subdivisionsintThe number of recursive subdivisions applied to each icosahedron triangle. Higher values produce more sampling directions and better coverage, but increase computation. Default is 3.
Returns
- List<JVector>
A list of JVector points on the convex hull, sampled using directional support mapping from a refined spherical distribution.
Remarks
This method begins with a regular icosahedron and recursively subdivides each triangular face into smaller triangles, projecting new vertices onto the unit sphere. Each final vertex direction is passed to the support mapper to generate a hull point. The time complexity is O(4^n), where n is the number of subdivisions.
SampleHull<TSupport>(in TSupport, int)
Samples a convex shape's hull by evaluating support directions generated through recursive subdivision of an icosahedron.
public static List<JVector> SampleHull<TSupport>(in TSupport support, int subdivisions = 3) where TSupport : ISupportMappable
Parameters
supportTSupportAn object implementing ISupportMappable, representing a convex shape that can be queried with directional support mapping.
subdivisionsintThe number of recursive subdivisions applied to each icosahedron triangle. Higher values produce more sampling directions and better coverage, but increase computation. Default is 3.
Returns
- List<JVector>
A list of JVector points on the convex hull, sampled using directional support mapping from a refined spherical distribution.
Type Parameters
TSupport
Remarks
This method begins with a regular icosahedron and recursively subdivides each triangular face into smaller triangles, projecting new vertices onto the unit sphere. Each final vertex direction is passed to the support mapper to generate a hull point. The time complexity is O(4^n), where n is the number of subdivisions.
Tessellate(IEnumerable<JVector>, int)
Creates a tessellation of the convex hull of a given set of 3D vertices.
public static List<JTriangle> Tessellate(IEnumerable<JVector> vertices, int subdivisions = 3)
Parameters
verticesIEnumerable<JVector>The vertices used to approximate the hull.
subdivisionsintThe number of subdivisions used for hull generation.
Returns
Remarks
The tessellated hull may not be perfectly convex. It is therefore not suited to be used with ConvexHullShape. The time complexity is O(4^n), where n is the number of subdivisions.
Tessellate(ReadOnlySpan<JVector>, int)
Creates a tessellation of the convex hull of a given set of 3D vertices.
public static List<JTriangle> Tessellate(ReadOnlySpan<JVector> vertices, int subdivisions = 3)
Parameters
verticesReadOnlySpan<JVector>The vertices used to approximate the hull.
subdivisionsintThe number of subdivisions used for hull generation.
Returns
Remarks
The tessellated hull may not be perfectly convex. It is therefore not suited to be used with ConvexHullShape. The time complexity is O(4^n), where n is the number of subdivisions.
Tessellate<TSupport>(in TSupport, int)
Creates a tessellation of a shape defined by its support map.
public static List<JTriangle> Tessellate<TSupport>(in TSupport support, int subdivisions = 3) where TSupport : ISupportMappable
Parameters
supportTSupportThe support map interface implemented by the shape.
subdivisionsintThe number of subdivisions used for hull generation.
Returns
Type Parameters
TSupport
Remarks
The tessellated hull may not be perfectly convex. It is therefore not suited to be used with ConvexHullShape. The time complexity is O(4^n), where n is the number of subdivisions.
Tessellate<TSupport, TCollection>(in TSupport, TCollection, int)
Creates a tessellation of a shape defined by its support map.
public static void Tessellate<TSupport, TCollection>(in TSupport support, TCollection hullCollection, int subdivisions = 3) where TSupport : ISupportMappable where TCollection : class, ICollection<JTriangle>
Parameters
supportTSupportThe support map interface implemented by the shape.
hullCollectionTCollectionA collection to which the triangles are added.
subdivisionsintThe number of subdivisions used for hull generation.
Type Parameters
TSupportTCollection
Remarks
The tessellated hull may not be perfectly convex. It is therefore not suited to be used with ConvexHullShape. The time complexity is O(4^n), where n is the number of subdivisions.
Tessellate<TSupport, TSink>(in TSupport, ref TSink, int)
Creates a tessellation of a shape defined by its support map and appends all generated triangles to the specified sink.
public static void Tessellate<TSupport, TSink>(in TSupport support, ref TSink hullSink, int subdivisions = 3) where TSupport : ISupportMappable where TSink : ISink<JTriangle>
Parameters
supportTSupportThe support map interface implemented by the shape.
hullSinkTSinkThe sink receiving the generated triangles.
subdivisionsintThe number of subdivisions used for hull generation.
Type Parameters
TSupportThe support shape type.
TSinkThe sink type receiving the generated triangles.
Remarks
The tessellated hull may not be perfectly convex. It is therefore not suited to be used with ConvexHullShape. The time complexity is O(4^n), where n is the number of subdivisions.