Class ShapeHelper
Provides helper methods for calculating the properties of implicitly defined shapes.
public static class ShapeHelper
- Inheritance
-
ShapeHelper
- Inherited Members
Methods
CalculateBoundingBox(ISupportMappable, in JQuaternion, in JVector, out JBoundingBox)
Calculates the axis-aligned bounding box of a shape given its orientation and position.
public static void CalculateBoundingBox(ISupportMappable support, in JQuaternion orientation, in JVector position, out JBoundingBox box)
Parameters
supportISupportMappableThe support map interface implemented by the shape.
orientationJQuaternionThe orientation of the shape.
positionJVectorThe position of the shape.
boxJBoundingBoxThe resulting bounding box.
CalculateMassInertia(ISupportMappable, out JMatrix, out JVector, out float, int)
Calculates the mass properties of an implicitly defined shape, assuming unit mass density.
public static void CalculateMassInertia(ISupportMappable support, out JMatrix inertia, out JVector centerOfMass, out float mass, int subdivisions = 4)
Parameters
supportISupportMappableThe 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).
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(ISupportMappable, int)
[Obsolete("Use Tessellate instead.")]
public static List<JTriangle> MakeHull(ISupportMappable support, int subdivisions = 3)
Parameters
supportISupportMappablesubdivisionsint
Returns
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<T>(ISupportMappable, T, int)
[Obsolete("Use Tessellate instead.")]
public static void MakeHull<T>(ISupportMappable support, T hullCollection, int subdivisions = 3) where T : class, ICollection<JTriangle>
Parameters
supportISupportMappablehullCollectionTsubdivisionsint
Type Parameters
T
SampleHull(ISupportMappable, int)
Samples a convex shape's hull by evaluating support directions generated through recursive subdivision of an icosahedron.
public static List<JVector> SampleHull(ISupportMappable support, int subdivisions = 3)
Parameters
supportISupportMappableAn 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.
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.
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.
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.
Tessellate(ISupportMappable, int)
Creates a tessellation of a shape defined by its support map.
public static List<JTriangle> Tessellate(ISupportMappable support, int subdivisions = 3)
Parameters
supportISupportMappableThe support map interface implemented by the shape.
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.
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.
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.
Tessellate<T>(ISupportMappable, T, int)
Creates a tessellation of a shape defined by its support map.
public static void Tessellate<T>(ISupportMappable support, T hullCollection, int subdivisions = 3) where T : class, ICollection<JTriangle>
Parameters
supportISupportMappableThe support map interface implemented by the shape.
hullCollectionTA collection to which the triangles are added.
subdivisionsintThe number of subdivisions used for hull generation.
Type Parameters
T
Remarks
The tessellated hull may not be perfectly convex. It is therefore not suited to be used with ConvexHullShape.
Tessellate<TSink>(ISupportMappable, 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<TSink>(ISupportMappable support, ref TSink hullSink, int subdivisions = 3) where TSink : ISink<JTriangle>
Parameters
supportISupportMappableThe support map interface implemented by the shape.
hullSinkTSinkThe sink receiving the generated triangles.
subdivisionsintThe number of subdivisions used for hull generation.
Type Parameters
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.