Table of Contents

Class ShapeHelper

Namespace
Jitter2.Collision.Shapes
Assembly
Jitter2.dll

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

support TSupport

The support map interface implemented by the shape.

orientation JQuaternion

The orientation of the shape.

position JVector

The position of the shape.

box JBoundingBox

The 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

support TSupport

The support map interface implemented by the shape.

inertia JMatrix

Output parameter for the inertia tensor calculated relative to the Origin (0,0,0).

centerOfMass JVector

Output parameter for the calculated center of mass vector (relative to the Origin).

mass float

Output parameter for the calculated mass (Volume * density 1.0).

subdivisions int

The 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

vertices IEnumerable<JVector>
subdivisions int

Returns

List<JTriangle>

MakeHull(ReadOnlySpan<JVector>, int)

[Obsolete("Use Tessellate instead.")]
public static List<JTriangle> MakeHull(ReadOnlySpan<JVector> vertices, int subdivisions = 3)

Parameters

vertices ReadOnlySpan<JVector>
subdivisions int

Returns

List<JTriangle>

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

support TSupport
subdivisions int

Returns

List<JTriangle>

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

support TSupport
hullCollection TCollection
subdivisions int

Type Parameters

TSupport
TCollection

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

vertices IEnumerable<JVector>

The vertices used to approximate the hull.

subdivisions int

The 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

vertices ReadOnlySpan<JVector>

The vertices used to approximate the hull.

subdivisions int

The 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

support TSupport

An object implementing ISupportMappable, representing a convex shape that can be queried with directional support mapping.

subdivisions int

The 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

vertices IEnumerable<JVector>

The vertices used to approximate the hull.

subdivisions int

The number of subdivisions used for hull generation.

Returns

List<JTriangle>

A list of triangles representing the convex hull.

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

vertices ReadOnlySpan<JVector>

The vertices used to approximate the hull.

subdivisions int

The number of subdivisions used for hull generation.

Returns

List<JTriangle>

A list of triangles representing the convex hull.

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

support TSupport

The support map interface implemented by the shape.

subdivisions int

The number of subdivisions used for hull generation.

Returns

List<JTriangle>

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

support TSupport

The support map interface implemented by the shape.

hullCollection TCollection

A collection to which the triangles are added.

subdivisions int

The number of subdivisions used for hull generation.

Type Parameters

TSupport
TCollection

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

support TSupport

The support map interface implemented by the shape.

hullSink TSink

The sink receiving the generated triangles.

subdivisions int

The number of subdivisions used for hull generation.

Type Parameters

TSupport

The support shape type.

TSink

The 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.