geomc 1.0
A c++ linear algebra template library
|
A simplex in N dimensions (e.g. a tetrahedron, triangle, line, point). More...
#include <geomc/shape/Simplex.h>
Public Types | |
using | elem_t |
The coordinate type of this object. | |
using | point_t |
The type of a point in this object's space. | |
Public Member Functions | |
constexpr | Simplex () |
Construct an empty simplex, with no vertices. | |
Simplex (const Vec< T, N > *verts, index_t n) | |
Construct an n -cornered simplex with vertices at verts . | |
Simplex (std::initializer_list< Vec< T, N > > verts) | |
Vec< T, N > | barycenter () const |
Compute the barycenter of this simplex. | |
Rect< T, N > | bounds () const |
Produces an axis-aligned box completely enclosing this shape. | |
Vec< T, N > | clip (const Vec< T, N > &p, Simplex< T, N > *onto=nullptr) const |
Ensure p lies within the simplex by orthogonally projecting it to the nearest point on the surface if it lies outside. | |
bool | contains (Vec< T, N > p) const |
Shape-point overlap test. | |
bool | contains (const Vec< T, N > &p) const |
Simplex-point intersection test. | |
Vec< T, N > | convex_support (Vec< T, N > d) const |
void | exclude (index_t i) |
Simplex< T, N > | excluded (index_t i) const |
Create a new sub-simplex by excluding the i th vertex in this simplex. | |
void | insert (Vec< T, N > p) |
Extend this simplex to include p by adding p as a vertex. | |
Rect< T, 1 > | intersect (const Ray< T, N > &r) const |
Ray-shape intersection. | |
bool | intersects (const Convex< T, N, Shape > &other) const |
Convex shape overlap test. | |
bool | is_facing (const Vec< T, N > &p, Vec< T, N > *params=nullptr) const |
Project the point to the simplex along its orthogonal complement (if there is one) and test for containment. | |
T | measure () const |
Return the positive volume of the simplex within the subspace that it spans. | |
T | measure_interior () const |
Compute the signed volume of the simplex. | |
Vec< T, N > | normal (Vec< T, N > p) const |
bool | operator!= (const Simplex< T, N > &other) const |
Simplex inequality check. | |
Simplex< T, N > & | operator*= (const AffineTransform< T, N > &xf) |
Apply a transformation to the points of this Simplex. | |
Simplex< T, N > & | operator/= (const AffineTransform< T, N > &xf) |
Apply an inverse transformation to the points of this Simplex. | |
bool | operator== (const Simplex< T, N > &other) const |
Simplex equality check. | |
Vec< T, N > & | operator[] (index_t i) |
Get the i th vertex in this simplex. | |
Vec< T, N > | operator[] (index_t i) const |
Get the i th vertex in this simplex. | |
Simplex< T, N > | operator| (const Vec< T, N > &p) const |
Return a copy of this simplex with an additional vertex at p . | |
Simplex< T, N > & | operator|= (const Vec< T, N > &p) |
Extend this simplex to include p by adding p as a vertex. | |
Vec< T, N > | project (Vec< T, N > p, Simplex< T, N > *face=nullptr) const |
T | sdf (Vec< T, N > p) const |
Signed distance function. | |
T | sdf (Vec< T, N > p, Vec< T, N > *normal=nullptr) const |
Return the signed distance to the surface of the shape. | |
Static Public Member Functions | |
static constexpr bool | admits_cusps () |
static constexpr Simplex | regular_simplex (index_t n=N+1) |
Construct a simplex with all edges of unit length and one edge along the x-axis. | |
static constexpr Simplex | standard_simplex () |
Construct a simplex with its vertices on the unit axes. | |
Public Attributes | |
index_t | n |
Number of vertices in this simplex. | |
Vec< T, N > | pts [N+1] |
Vertices of this simplex. | |
Static Public Attributes | |
static constexpr index_t | N |
The dimension of this object. | |
A simplex in N dimensions (e.g. a tetrahedron, triangle, line, point).
The simplex may contain up to N + 1
points, in which case it encloses a volume, if it is not degenerate. If it contains fewer points, then it spans a subspace of the space in which it is embedded.
|
inherited |
The type of a point in this object's space.
An N-vector of T if N > 1, otherwise a T.
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.
|
inline |
Ensure p
lies within the simplex by orthogonally projecting it to the nearest point on the surface if it lies outside.
The point is unchanged if p
is already inside the simplex.
p | The point to project onto the surface of this simplex. |
onto | Optional output parameter to receive the sub-simplex onto which p was projected. It is permissible for onto to alias this . |
p
's projection.
|
inlineinherited |
Shape-point overlap test.
Return true
if the point p
is on the surface or interior of the shape, false
otherwise.
Simplex-point intersection test.
If this simplex has fewer than N + 1
vertices, this simplex is not a volume, and this function returns false
.
If the simplex is degenerate (two or more coincident points), then it is also considered empty and this function returns false
.
p | A point. |
true
if p
is on or inside this simplex; false
otherwise. Extend this simplex to include p
by adding p
as a vertex.
If this Simplex already has N+1
vertices, then this function has no effect.
Ray-shape intersection.
Return the interval over which the ray intersects the simplex.
If the simplex is N-1 dimensional (i.e., planar, like a triangle in 3D), then an intersecting interval will have both of its limits equal to the single value of s
for which the ray o + s*v
intersects the simplex.
Simplexes with fewer than N-1 dimensions cannot be intersected, and the interval will always be empty.
Convex shape overlap test.
other
; false otherwise.
|
inline |
Project the point to the simplex along its orthogonal complement (if there is one) and test for containment.
p | A point. |
params | Optional return variable; return the n - 1 surface parameters of this simplex representing the projection of p onto the space spanned by this simplex. |
true
if p
is on or inside this simplex after projection; false
otherwise.
|
inline |
Return the positive volume of the simplex within the subspace that it spans.
For example, if the simplex has three points, it spans a plane and this function returns the area within the plane. If it has four, it returns the volume of the tetrahedron; or if it has two, the length of the line segment; and so on.
|
inline |
Compute the signed volume of the simplex.
If the simplex is not a full volume (i.e., the number of vertices is less than N+1
), then its volume is zero.
Simplex equality check.
Simplexes are equal if they have identical vertices in identical order.
Return a copy of this simplex with an additional vertex at p
.
If this simplex already has N + 1
points, a copy of this simplex is returned.
Extend this simplex to include p
by adding p
as a vertex.
Alias for insert(p)
.
If this Simplex already has N+1
vertices, then this operator has no effect.
|
inlinestaticconstexpr |
Construct a simplex with all edges of unit length and one edge along the x-axis.
n
is the number of vertices in the simplex.
|
inlineinherited |
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.