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 | |
typedef PointType< T, N >::point_t | point_t |
typedef T | elem_t |
The coordinate type of this shape. | |
Public Member Functions | |
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 . | |
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. | |
bool | operator== (const Simplex< T, N > &other) const |
Simplex equality check. More... | |
bool | operator!= (const Simplex< T, N > &other) const |
Simplex inequality check. | |
Simplex< T, N > | operator| (const Vec< T, N > &p) const |
Return a copy of this simplex with an additional vertex at p . More... | |
Simplex< T, N > & | operator|= (const Vec< T, N > &p) |
Extend this simplex to include p by adding p as a vertex. More... | |
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. | |
Rect< T, 1 > | intersect (const Ray< T, N > &r) const |
Ray-shape intersection. More... | |
bool | projection_contains (const Vec< T, N > &p, Vec< T, N > *params=nullptr) const |
Project the point to the simplex along its orthogonal basis (if there is one) and test for containment. More... | |
T | volume () const |
Compute the volume of the simplex. More... | |
bool | contains (const Vec< T, N > &p) const |
Simplex-point intersection test. More... | |
T | sdf (Vec< T, N > p) const |
Return the signed distance to the surface of the shape. | |
Simplex< T, N > | exclude (index_t i) const |
Create a new sub-simplex by excluding the i th vertex in this simplex. | |
Vec< T, N > | project (const Vec< T, N > &p, Simplex< T, N > *onto=nullptr) const |
Project p to the nearest point on the simplex. More... | |
Rect< T, N > | bounds () const |
Vec< T, N > | convex_support (Vec< T, N > d) const |
bool | intersects (const Convex< T, N, Shape > &other) const |
Convex shape overlap test. More... | |
bool | contains (Vec< T, N > p) const |
Shape-point overlap test. More... | |
Public Attributes | |
Vec< T, N > | pts [N+1] |
Vertices of this simplex. | |
index_t | n |
Number of vertices in this simplex. | |
Static Public Attributes | |
static constexpr size_t | N = _N |
The dimension of this shape. | |
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.
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.
|
inlineinherited |
Shape-point overlap test.
Return true
if the point p
is on the surface or interior of the shape, false
otherwise.
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. 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.
If this Simplex already has N+1
vertices, then this operator has no effect.
Project p
to the nearest point on the simplex.
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. Project the point to the simplex along its orthogonal basis (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 |
Compute the 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.