geomc 1.0
A c++ linear algebra template library
Loading...
Searching...
No Matches
Capsule< T, N > Class Template Reference

An N-dimensional capsule shape. More...

#include <geomc/shape/Capsule.h>

Inheritance diagram for Capsule< T, N >:
Convex< T, N, Capsule< T, N > > RayIntersectable< T, N, Capsule< T, N > > Projectable< T, N, Capsule< T, N > > Bounded< T, N, Capsule< T, N > > SdfEvaluable< T, N, Capsule< T, N > > Dimensional< T, N >

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 Capsule ()
 
constexpr Capsule (point_t p0, point_t p1, T r)
 
Vec< T, Naxis () const
 
Rect< T, Nbounds () const
 
Vec< T, Nclip (Vec< T, N > p) const
 Nearest point on the interior of the shape.
 
bool contains (point_t p) const
 Shape-point intersection test.
 
bool contains (Vec< T, N > p) const
 Shape-point overlap test.
 
point_t convex_support (point_t d) const
 
Rect< T, 1 > intersect (const Ray< T, N > &r) const
 Ray/shape intersection.
 
bool intersects (Sphere< T, N > s) const
 
bool intersects (const Convex< T, N, Shape > &other) const
 Convex shape overlap test.
 
measure_boundary () const
 Measure of the shape's boundary.
 
measure_interior () const
 Measure of the shape's interior.
 
point_t nearest_axis_point (point_t p) const
 
point_t normal (point_t p) const
 Outward-facing direction.
 
Vec< T, Nnormal (Vec< T, N > p) const
 Unit-length outward-facing direction.
 
bool operator== (const Capsule &other) const
 
point_t project (point_t p) const
 
Vec< T, Nproject (Vec< T, N > p) const
 Nearest point on the surface of the shape.
 
sdf (point_t p) const
 Signed distance function.
 
sdf (Vec< T, N > p) const
 

Static Public Member Functions

static constexpr bool admits_cusps ()
 

Public Attributes

point_t p0
 endpoints of the capsule axis.
 
point_t p1
 
radius
 

Static Public Attributes

static constexpr index_t N
 The dimension of this object.
 

Detailed Description

template<typename T, index_t N>
class geom::Capsule< T, N >

An N-dimensional capsule shape.

Member Typedef Documentation

◆ point_t

using point_t
inherited

The type of a point in this object's space.

An N-vector of T if N > 1, otherwise a T.

Constructor & Destructor Documentation

◆ Capsule()

template<typename T, index_t N>
Capsule ( )
inlineconstexpr

Construct a capsule centered on the origin, with radius 1, and axis from x = -1 to x = 1.

Member Function Documentation

◆ clip()

Vec< T, N > clip ( Vec< T, N > p) const
inlineinherited

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.

◆ contains()

bool contains ( Vec< T, N > p) const
inlineinherited

Shape-point overlap test.

Return true if the point p is on the surface or interior of the shape, false otherwise.

◆ intersect()

Rect< T, 1 > intersect ( const Ray< T, N > & r) const
inlineinherited

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.

◆ intersects() [1/2]

template<typename T, index_t N>
bool intersects ( Sphere< T, N > s) const
inline

Sphere-capsule intersection test.

Parameters
sAnother sphere.
Returns
true if s overlaps with this sphere's volume, false otherwise.

◆ intersects() [2/2]

bool intersects ( const Convex< T, N, Shape > & other) const
inlineinherited

Convex shape overlap test.

Returns
True if and only if this convex shape overlaps other; false otherwise.

◆ normal()

Vec< T, N > normal ( Vec< T, N > p) const
inlineinherited

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().

◆ project() [1/2]

template<typename T, index_t N>
point_t project ( point_t p) const
inline

Return the point p orthogonally projected onto the surface of the shape.

◆ project() [2/2]

Vec< T, N > project ( Vec< T, N > p) const
inlineinherited

Nearest point on the surface of the shape.

Compute the point on the boundary of the shape which is closest to p.

Member Data Documentation

◆ radius

template<typename T, index_t N>
T radius

Radius of the capsule; i.e. the distance from the axis which is inside the capsule.


The documentation for this class was generated from the following file: