geomc 1.0
A c++ linear algebra template library
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Cylinder< T, N > Class Template Reference

An N-dimensional cylinder, given by its radius and endpoints. More...

#include <geomc/shape/Cylinder.h>

Inheritance diagram for Cylinder< T, N >:
Convex< T, N, Cylinder< T, N > > RayIntersectable< T, N, Cylinder< T, N > > Projectable< T, N, Cylinder< T, N > > Bounded< T, _N, Derived > SdfEvaluable< T, N, Derived >

Public Types

typedef PointType< T, N >::point_t point_t
 
typedef T elem_t
 The coordinate type of this shape.
 

Public Member Functions

 Cylinder ()
 Construct a cylinder of radius and length 1, with axis along X+.
 
 Cylinder (T r)
 Construct a cylinder of radius r and length 1, with axis along X+.
 
 Cylinder (const Vec< T, N > &p0, const Vec< T, N > &p1, T radius)
 Construct a cylinder with arbitrary radius and endpoints. More...
 
bool contains (Vec< T, N > p) const
 Shape-point intersection test.
 
sdf (Vec< T, N > p) const
 Signed distance function.
 
Vec< T, Nproject (Vec< T, N > p) const
 
Rect< T, Nbounds () const
 
Vec< T, Nconvex_support (Vec< T, N > d) const
 
Rect< T, 1 > intersect (const Ray< T, N > &ray) const
 Ray/shape intersection test.
 
bool intersects (const Convex< T, N, Shape > &other) const
 Convex shape overlap test. More...
 
Vec< T, Nnormal (Vec< T, N > p) const
 Unit-length outward-facing direction. More...
 
Vec< T, Nclip (Vec< T, N > p) const
 Nearest point on the interior of the shape. More...
 

Public Attributes

Vec< T, Np0
 Axis endpoint.
 
Vec< T, Np1
 Axis endpoint.
 
radius
 Cylinder radius.
 

Static Public Attributes

static constexpr size_t N = _N
 The dimension of this shape.
 

Detailed Description

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

An N-dimensional cylinder, given by its radius and endpoints.

Represents an extrusion of an N-2 sphere. In other words, an extrusion of a disk in 3D; an extrusion of a sphere in 4D; and an extrusion of a line segment in 2D.

If p0 == p1, the behavior is undefined.

Constructor & Destructor Documentation

◆ Cylinder()

Cylinder ( const Vec< T, N > &  p0,
const Vec< T, N > &  p1,
radius 
)
inline

Construct a cylinder with arbitrary radius and endpoints.

Parameters
p0An endpoint of the cylinder axis.
p1An endpoint of the cylinder axis.
radiusRadius of cylinder.

Member Function Documentation

◆ bounds()

Rect< T, N > bounds ( ) const
inline
Returns
An axis-aligned bounding box completely containing this cylinder.

◆ 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.

◆ intersects()

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


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