geomc 1.0
A c++ linear algebra template library
|
An N-dimensional frustum (truncated pyramid) with an arbitrary Convex shape as its base, and its (possibly excluded) point at the origin. More...
#include <geomc/shape/Frustum.h>
Public Types | |
typedef Shape::elem_t | T |
The coordinate type of this Shape. | |
typedef PointType< T, Shape::N >::point_t | base_point_t |
Point type of the base shape. | |
typedef PointType< Shape::elem_t, N >::point_t | point_t |
typedef T | elem_t |
The coordinate type of this shape. | |
Public Member Functions | |
Frustum () | |
Construct a pyramid with its tip at the origin and a default-constructed cross-sectional base at h=1. | |
Frustum (const Shape &base, T h0, T h1) | |
Construct a new Frustum having base as a cross section, and spanning heights between h0 and h1 . | |
Frustum (const Shape &base, const Rect< T, 1 > &h) | |
Construct a new Frustum having base as a cross section, and spanning the height range h . | |
bool | contains (Vec< T, N > p) const |
Rect< T, 1 > | intersect (const Ray< T, N > &ray) const |
Ray-shape intersection. | |
Vec< T, N > | convex_support (Vec< T, N > d) const |
Rect< T, N > | bounds () const |
Rect< T, 1 > | clipped_height () const |
Return the height range of this Frustum after it has been clipped by the origin. | |
point_t | convex_support (point_t d) const |
Geometric convex support function. More... | |
bool | intersects (const Convex< Shape::elem_t, N, Shape > &other) const |
Convex shape overlap test. More... | |
Public Attributes | |
Shape | base |
Cross-section of this frustum at the h=1 plane. | |
Rect< T, 1 > | height |
Height range spanned by this frustum. | |
Static Public Attributes | |
static constexpr size_t | N = Shape::N + 1 |
The dimension of this Shape. | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T , index_t N> | |
using | ViewFrustum = Oriented< Frustum< Rect< T, N-1 > > > |
Convenience typedef for oriented, rectangular, N-dimensional Frustums. | |
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. | |
An N-dimensional frustum (truncated pyramid) with an arbitrary Convex shape as its base, and its (possibly excluded) point at the origin.
The first N-1 dimensions have cross-sections which are Shape
s. The last dimension is the "height" of the frustum. The base Shape
is specified lying on the h = 1
plane. (Note that below the origin, the base shape will be flipped due to the change of sign).
If the height range spans height = 0
, then the height extending below the origin is excluded from the shape. Use clipped_height()
to obtain the height range actually spanned by the shape. (A frustum spanning the origin would not be convex).
Oriented, Rect-based Frustums are very commonly needed to represent viewing frustums; for these consider using ViewFrustum
, which is a templated type alias for Oriented<Frustum<Rect>>
.
Frustum-point intersection test.
p | A point. |
true
if p
is on or inside this frustum; 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. |
Convex shape overlap test.
other
; false otherwise.