geomc 1.0
A c++ linear algebra template library
|
Shape-related functions and classes. More...
Topics | |
Spline | |
Splines and curves. | |
Concepts | |
concept | geom::BoundedObject |
A shape which can efficiently report its bounding box. | |
concept | geom::ConvexObject |
A convex shape which implements its convex support function. | |
concept | geom::RayIntersectableObject |
A shape which can be intersected by a ray. | |
concept | geom::RegionObject |
A shape which can test for point containment. | |
concept | geom::SdfObject |
A shape which can report its exact signed distance field. | |
concept | geom::InteriorMeasurableObject |
A shape which can measure its interior region. | |
concept | geom::BoundaryMeasurableObject |
A shape which can measure its boundary. | |
concept | geom::MeasurableObject |
A shape which can measure both its surface area and volume. | |
concept | geom::ProjectableObject |
A shape which can perform an orthogonal projection to its boundary. | |
Classes | |
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 | Bounded< T, N, Derived > |
Base class describing shapes with finite extents in N dimensions. More... | |
class | Capsule< T, N > |
An N-dimensional capsule shape. More... | |
class | Convex< T, N, Derived > |
Base class describing convex shapes in N-dimensional space. More... | |
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 | Extruded< 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 | Hollow< Shape > |
Selects the boundary of a shape. More... | |
class | KDTree< T, N, Object, NodeData > |
A hierarchical spatial index. More... | |
class | Plane< T, N > |
A geometric plane or hyperplane. 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 | RayIntersectable< T, N, Derived > |
Base class describing N-dimensional shapes which can be intersection-tested with a Ray. More... | |
class | Rect< T, N > |
An N-dimensional axis-aligned interval. More... | |
class | SdfEvaluable< T, N, Derived > |
Base class describing N-dimensional shapes which implement a signed distance function. More... | |
class | Similar< Shape > |
A shape transformed by a similarity transform (translation, rotation, and scale). More... | |
class | Simplex< T, N > |
A simplex in N dimensions (e.g. a tetrahedron, triangle, line, point). More... | |
class | Sphere< T, N > |
An N-dimensional circle, sphere, or hypersphere with a filled interior. More... | |
class | SphericalCap< T, N > |
The surface of a sphere within a certain angle from its pole. More... | |
class | Transformed< Shape > |
A wrapper shape which transforms another arbitrary shape with an AffineTransform. More... | |
class | Transformed< Rect< T, N > > |
Partial specialization of Transformed for Rects. | |
Macros | |
#define | MAX_KDTREE_ARITY 16 |
Typedefs | |
template<typename T, index_t N> | |
using | AffineBox = Transformed<Rect<T,N>> |
Convenience typedef for transformed Rects. | |
template<typename T, index_t N> | |
using | Box = Similar<Rect<T,N>> |
Convenience typedef for arbitrarily-oriented Rects. | |
template<typename T> | |
using | Circle = Sphere<T,2> |
A 2D circle. | |
template<typename T> | |
using | Cone = Frustum<Circle<T>> |
Convenience typedef for a 3D cone with its tip at the origin. | |
template<typename T, index_t N> | |
using | SphericalShell = Dilated<Hollow<Sphere<T,N>>> |
Convenience typedef for a spherical shell. | |
typedef Shape::elem_t | T |
template<typename T> | |
using | Tetrahedron = Simplex<T,3> |
template<typename T> | |
using | TransformedCone = Transformed<Cone<T>> |
Convenience typedef for an oriented cone. | |
template<typename T> | |
using | Triangle = Simplex<T,2> |
template<typename T, index_t N> | |
using | ViewFrustum = Transformed< Frustum< Rect<T,N-1> > > |
Convenience typedef for oriented, rectangular, N-dimensional Frustums. | |
Enumerations | |
enum | ArrayOrder { ARRAYORDER_FIRST_DIM_CONSECUTIVE , ARRAYORDER_LAST_DIM_CONSECUTIVE } |
Array traversal order, specified in terms of which axes to increment first. More... | |
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 | KDInsertionChoice { INSERT_SMALLEST_VOLUME_INCREASE , INSERT_SHORTEST_DISTANCE } |
Strategy for insertion of an object into an existing tree. 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... | |
Functions | |
AnyConvexImpl (const Shape &&s) | |
AnyConvexImpl (const Shape &s) | |
virtual Rect< T, N > | _impl_bounds () const =0 |
virtual Rect< T, N > | _impl_bounds () const |
virtual point_t | _impl_convex_support (Vec< T, N > p) const =0 |
virtual point_t | _impl_convex_support (Vec< T, N > p) const |
template<typename Shape> | |
AnyConvexImpl< Shape > | as_any_convex (const Shape &s) |
Wrap s in a virtual class which implements the Convex concept. | |
Rect< T, N > | bounds () const |
Rect< T, N > | bounds () const |
Produces an axis-aligned box completely enclosing this shape. | |
Rect< T, N > | bounds () const |
Produces an axis-aligned box completely enclosing this shape. | |
Vec< T, N > | clip (Vec< T, N > p) const |
Nearest point on the interior of the shape. | |
bool | contains (Vec< T, N > p) const |
Shape-point overlap test. | |
point_t | convex_support (point_t d) const |
point_t | convex_support (point_t d) const |
Geometric convex support function. | |
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 Shape> | |
Dilated< Shape > | dilate (const Shape &s, typename Shape::elem_t dilation) |
Dilate the shape s by the amount dilation . | |
template<typename T, index_t N> | |
Sphere< T, N > | dilate (const Sphere< T, N > &s, T dilation) |
Dilate the Sphere s by the amount dilation . | |
template<typename T, index_t N> | |
Plane< T, N > | dilate (Plane< T, N > p, T dilation) |
Dilate the Plane p by the amount dilation . | |
template<typename Shape> | |
Extruded< 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 Extruded 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. | |
Rect< T, 1 > | intersect (const Ray< T, N > &r) const |
Ray/shape intersection. | |
template<typename Shape> | |
bool | intersects (const Convex< T, N, Shape > &other) const |
Convex shape overlap test. | |
template<typename T, index_t N> | |
bool | intersects (const AnyConvex< T, N > &shape_a, const AnyConvex< T, N > &shape_b) |
Vec< T, N > | normal (Vec< T, N > p) const |
Unit-length outward-facing direction. | |
template<typename T, index_t N> | |
Capsule< T, N > | operator* (const Isometry< T, N > &xf, const Capsule< T, N > &c) |
Transform a capsule by an isometry. | |
template<typename T, index_t N> | |
Cylinder< T, N > | operator* (const Isometry< T, N > &xf, const Cylinder< T, N > &c) |
Transform a cylinder by an isometry. | |
template<typename T, index_t N, typename Shape> | |
Dilated< Shape > | operator* (const Isometry< T, N > &xf, const Dilated< Shape > &s) |
Transform a dilated shape by an isometry. | |
template<typename T, index_t N> | |
Simplex< T, N > | operator* (const Isometry< T, N > &xf, const Simplex< T, N > &s) |
Transform a simplex by an isometry. | |
template<typename T, index_t N> | |
Sphere< T, N > | operator* (const Isometry< T, N > &xf, const Sphere< T, N > &s) |
Transform a sphere by an isometry. | |
template<typename Shape> | |
Similar< Shape > | operator* (const Similarity< typename Shape::elem_t, Shape::N > &xf, const Shape &shape) |
Transform the shape shape by wrapping it with a Similarity transform. | |
template<typename Shape> | |
Similar< Shape > | operator* (const Similarity< typename Shape::elem_t, Shape::N > &xf, const Similar< Shape > &s) |
Transform the shape s by xf . | |
template<typename T, index_t N> | |
Capsule< T, N > | operator* (const Similarity< T, N > &xf, const Capsule< T, N > &c) |
Transform a capsule by a similarity transform. | |
template<typename T, index_t N> | |
Cylinder< T, N > | operator* (const Similarity< T, N > &xf, const Cylinder< T, N > &c) |
Transform a cylinder by a similarity transform. | |
template<typename T, index_t N, typename Shape> | |
Dilated< Shape > | operator* (const Similarity< T, N > &xf, const Dilated< Shape > &s) |
Transform a dilated shape by a similarity transform. | |
template<typename T, index_t N> | |
Simplex< T, N > | operator* (const Similarity< T, N > &xf, const Simplex< T, N > &s) |
Transform a simplex by a similarity transform. | |
template<typename T, index_t N> | |
Sphere< T, N > | operator* (const Similarity< T, N > &xf, const Sphere< T, N > &s) |
Transform a sphere by a similarity transform. | |
template<typename Shape> | |
Transformed< Shape > | operator* (const AffineTransform< typename Shape::elem_t, Shape::N > &xf, const Shape &s) |
Transform the shape s by wrapping it in an Transformed class. | |
template<typename Shape> | |
Transformed< Shape > | operator* (const AffineTransform< typename Shape::elem_t, Shape::N > &xf, const Transformed< Shape > &s) |
Transform the transformed shape s by xf . | |
template<typename Shape, typename T, index_t N> | |
Transformed< Shape > | operator* (const Isometry< T, N > &xf, const Transformed< Shape > &s) |
Transform the shape s by an isometry xf . | |
template<typename Shape, typename T, index_t N> | |
Transformed< Shape > | operator* (const Similarity< T, N > &xf, const Transformed< Shape > &s) |
Transform the shape s by a similarity transform xf . | |
template<typename Shape> | |
Similar< Shape > & | operator*= (Similar< Shape > &s, const Similarity< typename Shape::elem_t, Shape::N > &xf) |
In-place transform the shape s by xf . | |
template<typename Shape> | |
Transformed< Shape > & | operator*= (Transformed< Shape > &s, const AffineTransform< typename Shape::elem_t, Shape::N > &xf) |
In-place transform the transformed shape s by xf . | |
template<typename T, index_t N> | |
Capsule< T, N > | operator/ (const Capsule< T, N > &c, const Isometry< T, N > &xf) |
Inverse-transform a capsule by an isometry. | |
template<typename T, index_t N> | |
Cylinder< T, N > | operator/ (const Cylinder< T, N > &c, const Isometry< T, N > &xf) |
Inverse-transform a cylinder by an isometry. | |
template<typename T, index_t N, typename Shape> | |
Dilated< Shape > | operator/ (const Dilated< Shape > &s, const Isometry< T, N > &xf) |
Inverse-transform a dilated shape by an isometry. | |
template<typename T, index_t N> | |
Simplex< T, N > | operator/ (const Simplex< T, N > &s, const Isometry< T, N > &xf) |
Inverse-transform a simplex by an isometry. | |
template<typename T, index_t N> | |
Sphere< T, N > | operator/ (const Sphere< T, N > &s, const Isometry< T, N > &xf) |
Inverse-transform a sphere by an isometry. | |
template<typename Shape> | |
Similar< Shape > | operator/ (const Shape &s, const Similarity< typename Shape::elem_t, Shape::N > &xf) |
Transform the shape s by the inverse of xf . | |
template<typename Shape> | |
Similar< Shape > | operator/ (const Similar< Shape > &s, const Similarity< typename Shape::elem_t, Shape::N > &xf) |
Transform the shape s by the inverse of xf . | |
template<typename T, index_t N> | |
Capsule< T, N > | operator/ (const Capsule< T, N > &c, const Similarity< T, N > &xf) |
Inverse-transform a capsule by a similarity transform. | |
template<typename T, index_t N> | |
Cylinder< T, N > | operator/ (const Cylinder< T, N > &c, const Similarity< T, N > &xf) |
Inverse-transform a cylinder by a similarity transform. | |
template<typename T, index_t N, typename Shape> | |
Dilated< Shape > | operator/ (const Dilated< Shape > &s, const Similarity< T, N > &xf) |
Inverse-transform a dilated shape by a similarity transform. | |
template<typename T, index_t N> | |
Simplex< T, N > | operator/ (const Simplex< T, N > &s, const Similarity< T, N > &xf) |
Inverse-transform a simplex by a similarity transform. | |
template<typename T, index_t N> | |
Sphere< T, N > | operator/ (const Sphere< T, N > &s, const Similarity< T, N > &xf) |
Inverse-transform a sphere by a similarity transform. | |
template<typename Shape> | |
Transformed< 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> | |
Transformed< Shape > | operator/ (const Transformed< Shape > &s, const AffineTransform< typename Shape::elem_t, Shape::N > &xf) |
Transform the transformed shape s by the inverse of xf . | |
template<typename Shape, typename T, index_t N> | |
Transformed< Shape > | operator/ (const Transformed< Shape > &s, const Isometry< T, N > &xf) |
Inverse transform the shape s by an isometry xf . | |
template<typename Shape, typename T, index_t N> | |
Transformed< Shape > | operator/ (const Transformed< Shape > &s, const Similarity< T, N > &xf) |
Inverse transform the shape s by a similarity transform xf . | |
template<typename Shape> | |
Similar< Shape > & | operator/= (Similar< Shape > &s, const Similarity< typename Shape::elem_t, Shape::N > &xf) |
In-place transform the shape s by the inverse of xf . | |
template<typename Shape> | |
Transformed< Shape > & | operator/= (Transformed< Shape > &s, const AffineTransform< typename Shape::elem_t, Shape::N > &xf) |
In-place transform the transformed shape s by the inverse of xf . | |
Vec< T, N > | project (Vec< T, N > p) const |
Nearest point on the surface of the shape. | |
template<typename T, index_t N> | |
Dilated< Rect< T, N > > | roundrect (const Rect< T, N > &rect, T radius) |
Produce a rounded rectangle with corner radius radius . | |
T | sdf (Vec< T, N > p) const |
T | sdf (Vec< T, N > p) const |
Signed distance function. | |
template<typename T, index_t N> | |
Dilated< Hollow< Sphere< T, N > > > | shell (const Sphere< T, N > &s, T thickness) |
Create a spherical shell with wall thickness thickness around the Sphere s . | |
template<typename T, index_t N> | |
Dilated< Hollow< Sphere< T, N > > > | shell (Vec< T, N > center, T r0, T r1) |
Create a spherical shell around center , with inner and outer radii r0 and r1 . | |
template<typename T, index_t N> | |
bool | trace_simplex (const Vec< T, N > verts[N], const Ray< T, N > &ray, Vec< T, N-1 > *uv, T *s) |
Variables | |
static constexpr index_t | N = Shape::N |
Shape | shape |
template<typename Shape, Transform< typename Shape::elem_t, Shape::N > Xf> | |
Hollow< Shape > | operator* (const Xf &xf, const Hollow< Shape > &s) |
Transform a hollow shape. | |
template<typename Shape, Transform< typename Shape::elem_t, Shape::N > Xf> | |
Hollow< Shape > | operator/ (const Hollow< Shape > &s, const Xf &xf) |
Inverse transform a hollow shape. | |
template<typename Shape, Transform< typename Shape::elem_t, Shape::N > Xf> | |
Hollow< Shape > & | operator*= (Hollow< Shape > &s, const Xf &xf) |
In-place transform a hollow shape. | |
template<typename Shape, Transform< typename Shape::elem_t, Shape::N > Xf> | |
Hollow< Shape > & | operator/= (Hollow< Shape > &s, const Xf &xf) |
In-place inverse transform a hollow shape. | |
Shape-related functions and classes.
A 2D circle.
T | Coordinate type |
Convenience typedef for a 3D cone with its tip at the origin.
Formed from a frustum with a circular base.
T | Coordinate type |
Convenience typedef for an oriented cone.
T | Coordinate type |
enum ArrayOrder |
Array traversal order, specified in terms of which axes to increment first.
|
strong |
Strategy for choosing an axis along which to split a group of objects in a spatial index.
|
strong |
|
strong |
|
inlineprotectedvirtual |
Implements AnyConvex< Shape::elem_t, Shape::N >.
|
inlineprotectedvirtual |
Implements AnyConvex< Shape::elem_t, Shape::N >.
Produces an axis-aligned box completely enclosing this shape.
The default implementation calls convex_support()
along each of the principal axes to find the extents.
Nearest point on the interior of the shape.
If p
is on the interior of the shape, return p
unaltered; otherwise orthogonally project p
to the shape's surface.
|
inline |
Shape-point overlap test.
Return true
if the point p
is on the surface or interior of the shape, false
otherwise.
Geometric convex support function.
Returns the point on the surface of this convex shape that is furthest along direction d
(i.e., has the highest dot product with d
).
All shapes which implement this function automatically support geometrical intersection tests with any other Convex object.
d | Direction along which to find a support plane. |
Dilate the Plane p
by the amount dilation
.
(This just moves the plane dilation
units along its normal).
|
inline |
Ray/shape intersection.
Return the possibly-empty range of ray parameters s
such that the Ray overlaps the shape at r.origin + s * r.direction
.
For non-convex objects with multiple regions of overlap, this method should return the interval containing the smallest positive value.
|
inline |
Convex shape overlap test.
other
; false otherwise. Unit-length outward-facing direction.
For any point, return the direction which points directly away from the nearest point on the shape, away from its interior.
This should be the same as the gradient of the sdf().
Nearest point on the surface of the shape.
Compute the point on the boundary of the shape which is closest to p
.
|
inline |
Produce a rounded rectangle with corner radius radius
.
The rounded rectangle will have the extents of rect
, but with corners rounded by radius
. The radius will be clamped to the maximum possible value that will not cause the corners to overlap.
|
inline |
Signed distance function.
Compute a signed distance to the nearest surface point on the shape. Points on the exterior have positive value; points on the interior have negative value; surface points have sdf value 0.
|
Create a spherical shell around center
, with inner and outer radii r0
and r1
.
It is not required that r0 < r1; the shell will always be constructed with positive thickness.
|
inline |
Ray trace an N-1 dimensional simplex (e.g. triangle in 3D, tetrahedron in 4D, a line in 2D etc.), returning the surface parameters of the hit point, given in coordinates of the basis spanned by the edges radiating from verts[0]
.
verts | An array of the simplex's N vertices. |
ray | The ray to intersect with the simplex. |
uv | Buffer for the surface coordinates of the hitpoint. (return variable; may be null). |
s | The ray parameter of the hit point. (return variable) |
true
if the ray hit the simplex.