geomc 1.0
A c++ linear algebra template library
Modules | Classes | Macros | Typedefs | Enumerations | Functions
Shape

Shape-related functions and classes. More...

Modules

 Traits
 Metadata about shape classes.
 

Classes

class  Cylinder< T, N >
 An N-dimensional cylinder, given by its radius and endpoints. More...
 
class  Dilated< Shape >
 A wrapper shape which dilates the extents of another Shape. More...
 
class  Extrusion< Shape >
 An axis-aligned extrusion of an arbitrary N-1 dimensional Convex shape. More...
 
class  Frustum< Shape >
 An N-dimensional frustum (truncated pyramid) with an arbitrary Convex shape as its base, and its (possibly excluded) point at the origin. More...
 
class  GridIterator< T, N, Order >
 Iterator over the integer points in an N-dimensional grid. More...
 
class  KDTree< T, N, Object, NodeData >
 A hierarchical spatial index. More...
 
class  Oriented< Shape >
 A wrapper shape which orients another arbitrary shape with an AffineTransform. More...
 
class  Oriented< Rect< T, N > >
 Partial specialization of Oriented for Rects. More...
 
class  Plane< T, N >
 A geometric plane or hyperplane. More...
 
class  Rect< T, N >
 An N-dimensional axis-aligned interval. More...
 
class  Bounded< T, _N, Derived >
 Base class describing shapes with finite extents in N dimensions. More...
 
class  Convex< T, N, Derived >
 Base class describing convex shapes in N-dimensional space. More...
 
class  RayIntersectable< T, N, Derived >
 Base class describing N-dimensional shapes which can be intersection-tested with a Ray. More...
 
class  SdfEvaluable< T, N, Derived >
 Base class describing N-dimensional shapes which implement a signed distance function. More...
 
class  Projectable< T, N, Derived >
 Base class describing N-dimensional shapes which implement the ability to project an arbitrary point to the nearest point on their surface. More...
 
class  AnyConvex< T, N >
 Helper class which virtualizes the static polymorphism of Convex shapes. More...
 
class  AnyConvexImpl< Shape >
 Implementation of AnyConvex for a specific Shape. More...
 
class  Sphere< T, N >
 A N-dimensional circle, sphere, or hypersphere. More...
 
class  Simplex< T, N >
 A simplex in N dimensions (e.g. a tetrahedron, triangle, line, point). More...
 
class  SphericalSector< T, N >
 A N-dimensional circle, sphere, or hypersphere. More...
 

Macros

#define MAX_KDTREE_ARITY   16
 

Typedefs

template<typename T , index_t N>
using ViewFrustum = Oriented< Frustum< Rect< T, N-1 > > >
 Convenience typedef for oriented, rectangular, N-dimensional Frustums.
 
template<typename T , index_t N>
using OrientedRect = Oriented< Rect< T, N > >
 Convenience typedef for oriented Rects.
 

Enumerations

enum class  KDAxisChoice { AXIS_LONGEST , AXIS_HIGHEST_VARIANCE , AXIS_CYCLICAL }
 Strategy for choosing an axis along which to split a group of objects in a spatial index. More...
 
enum class  KDPivotChoice { PIVOT_MEAN , PIVOT_MEDIAN }
 Strategy for choosing the pivot value when splitting a group of objects in a spatial index. More...
 
enum class  KDInsertionChoice { INSERT_SMALLEST_VOLUME_INCREASE , INSERT_SHORTEST_DISTANCE }
 Strategy for insertion of an object into an existing tree. More...
 
enum  ArrayOrder { ARRAYORDER_FIRST_DIM_CONSECUTIVE , ARRAYORDER_LAST_DIM_CONSECUTIVE }
 Array traversal order, specified in terms of which axes to increment first. More...
 

Functions

template<typename T , index_t N>
bool gjk_intersect (const AnyConvex< T, N > &shape_a, const AnyConvex< T, N > &shape_b, Vec< T, N > *overlap_axis=NULL)
 
template<typename T , index_t N>
bool minimal_separation_axis (const AnyConvex< T, N > &shape_a, const AnyConvex< T, N > &shape_b, Vec< T, N > *overlap_axis, double fractional_tolerance=0.001, index_t iteration_limit=-1, bool emit_debug=false)
 
template<typename Shape >
AnyConvexImpl< Shape > as_any_convex (const Shape &s)
 Wrap s in a virtual class which implements the Convex concept.
 
template<typename Shape >
Dilated< Shape > dilate (const Shape &s, typename Shape::elem_t dilation)
 Dilate the shape s by the amount dilation.
 
template<typename Shape >
Dilated< Shape > dilate (const Dilated< Shape > &s, typename Shape::elem_t dilation)
 Dilate the shape s by the amount dilation.
 
template<typename T , index_t N>
Plane< T, Ndilate (Plane< T, N > p, T dilation)
 Dilate the Plane p by the amount dilation. More...
 
template<typename T , index_t N>
Sphere< T, Ndilate (const Sphere< T, N > &s, T dilation)
 Dilate the Sphere s by the amount dilation. More...
 
template<typename Shape >
Extrusion< Shape > extrude (const Shape &s, typename Shape::elem_t h0, typename Shape::elem_t h1)
 Convenience function to extrude the shape s between heights h0 and h1 by wrapping s in the Extrusion template.
 
template<typename Shape >
Frustum< Shape > frustum (const Shape &s, typename Shape::elem_t h0, typename Shape::elem_t h1)
 Convenience function to raise the shape s into a frustum between heights h0 and h1, by wrapping s in the Frustum template.
 
template<typename Shape >
Oriented< Shape > operator* (const AffineTransform< typename Shape::elem_t, Shape::N > &xf, const Shape &s)
 Transform the shape s by wrapping it in an Oriented class.
 
template<typename Shape >
Oriented< Shape > operator* (const AffineTransform< typename Shape::elem_t, Shape::N > &xf, const Oriented< Shape > &s)
 Transform the oriented shape s by xf.
 
template<typename Shape >
Oriented< Shape > & operator*= (Oriented< Shape > &s, const AffineTransform< typename Shape::elem_t, Shape::N > &xf)
 In-place transform the oriented shape s by xf.
 
template<typename Shape >
Oriented< Shape > operator/ (const Shape &s, const AffineTransform< typename Shape::elem_t, Shape::N > &xf)
 Transform the shape s by the inverse of xf.
 
template<typename Shape >
Oriented< Shape > operator/ (const Oriented< Shape > &s, const AffineTransform< typename Shape::elem_t, Shape::N > &xf)
 Transform the oriented shape s by the inverse of xf.
 
template<typename Shape >
Oriented< Shape > & operator/= (Oriented< Shape > &s, const AffineTransform< typename Shape::elem_t, Shape::N > &xf)
 In-place transform the oriented shape s by the inverse of xf.
 

Detailed Description

Shape-related functions and classes.

Enumeration Type Documentation

◆ ArrayOrder

enum ArrayOrder

Array traversal order, specified in terms of which axes to increment first.

Enumerator
ARRAYORDER_FIRST_DIM_CONSECUTIVE 

Array traversal by incrementing the first coordinate in the innermost loop.

For matrices, whose coordinates are ordered (row, col), this represens column-major (i.e. "fortran") order. If coordinates are (x, y, ...), then this is row-major order.

ARRAYORDER_LAST_DIM_CONSECUTIVE 

Array traversal by incrementing the last coordinate in the innermost loop.

For matrices, whose coordinates are ordered (row, col), this represents row-major (i.e. "C") order. If coordinates are (x, y, ...), then this is column-major order.

◆ KDAxisChoice

enum class KDAxisChoice
strong

Strategy for choosing an axis along which to split a group of objects in a spatial index.

Enumerator
AXIS_LONGEST 

Divide a node along its longest axis.

AXIS_HIGHEST_VARIANCE 

Divide a node along the axis with the highest position variance.

AXIS_CYCLICAL 

Divide each node along an axis that cycles with tree depth, starting with the x (first) axis at the root node.

◆ KDInsertionChoice

enum class KDInsertionChoice
strong

Strategy for insertion of an object into an existing tree.

Enumerator
INSERT_SMALLEST_VOLUME_INCREASE 

Insert objects into the node that will experience the smallest volume increase as a result of the addition.

INSERT_SHORTEST_DISTANCE 

Insert objects into the node which is closest.

◆ KDPivotChoice

enum class KDPivotChoice
strong

Strategy for choosing the pivot value when splitting a group of objects in a spatial index.

Enumerator
PIVOT_MEAN 

Split a node at the population average.

PIVOT_MEDIAN 

Split a node at the population median.

Function Documentation

◆ dilate() [1/2]

Sphere< T, N > dilate ( const Sphere< T, N > &  s,
T  dilation 
)
related

Dilate the Sphere s by the amount dilation.

(This just adds the amount dilation to the Sphere's radius).

◆ dilate() [2/2]

Plane< T, N > dilate ( Plane< T, N p,
T  dilation 
)
related

Dilate the Plane p by the amount dilation.

(This just moves the plane dilation units along its normal).

◆ gjk_intersect()

bool geom::gjk_intersect ( const AnyConvex< T, N > &  shape_a,
const AnyConvex< T, N > &  shape_b,
Vec< T, N > *  overlap_axis = NULL 
)

Use the Gilbert-Johnson-Keerthi algorithm to determine if two convex shapes overlap, and return an axis of overlap.

Parameters
shape_aA convex shape.
shape_bA convex shape.
overlap_axisAn initial axis along which to test for overlap; upon completion this will be populated with an axis (not necessarily minimal) of overlap or separation. Pass null to choose an arbitrary initial axis.
Returns
true if and only if shape_a and shape_b overlap.

◆ minimal_separation_axis()

bool geom::minimal_separation_axis ( const AnyConvex< T, N > &  shape_a,
const AnyConvex< T, N > &  shape_b,
Vec< T, N > *  overlap_axis,
double  fractional_tolerance = 0.001,
index_t  iteration_limit = -1,
bool  emit_debug = false 
)

Use the Expanding Polytope Algorithm to find a minimum translation vector that would bring shape B into contact with A. If A and B are not interpenetrating the separation axis is undefined.

Parameters
shape_aA convex shape.
shape_bA convex shape.
overlap_axisAn initial test axis, and return variable for the separation vector.
fractional_toleranceConvergence condition: When the magnitude of the difference between iterations is less than this fraction of the total separation, terminate the algorithm.
iteration_limitHard limit on number of convergence iterations. Pass -1 (default) to impose no hard limit.
Returns
true if and only if the two shapes overlap.