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(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

support ISupportMappable

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.

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

support ISupportMappable

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

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

support ISupportMappable
subdivisions int

Returns

List<JTriangle>

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

support ISupportMappable
hullCollection T
subdivisions int

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

support ISupportMappable

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.

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

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.

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.

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

support ISupportMappable

The support map interface implemented by the shape.

subdivisions int

The number of subdivisions used for hull generation.

Returns

List<JTriangle>

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

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.

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.

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

support ISupportMappable

The support map interface implemented by the shape.

hullCollection T

A collection to which the triangles are added.

subdivisions int

The 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

support ISupportMappable

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

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.