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

An N-dimensional circle, sphere, or hypersphere with a filled interior. More...

#include <geomc/shape/Sphere.h>

Inheritance diagram for Sphere< T, N >:
Convex< T, N, Sphere< T, N > > RayIntersectable< T, N, Sphere< T, N > > Projectable< T, N, Sphere< T, N > > Bounded< T, N, Sphere< T, N > > SdfEvaluable< T, N, Sphere< 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 Sphere ()
 
constexpr Sphere (const point_t &c, T r)
 
constexpr Sphere (T r)
 
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.
 
point_t convex_support (point_t d) const
 
Rect< T, 1 > intersect (const Ray< T, N > &ray) const
 Shape-ray intersection test.
 
bool intersects (const Convex< T, N, Shape > &other) const
 Convex shape overlap test.
 
bool intersects (const Rect< T, N > &rect) const
 
bool intersects (Sphere s) const
 
measure_boundary () const
 Measure the boundary of the shape.
 
measure_interior () const
 Measure the interior (volume) of the shape.
 
point_t normal (point_t p) const
 Outward-facing direction.
 
bool operator== (const Sphere &other) const
 
point_t project (point_t p) const
 
sdf (point_t p) const
 Signed distance function.
 

Static Public Member Functions

static constexpr bool admits_cusps ()
 

Public Attributes

point_t center
 Center of the sphere.
 
r
 Radius of the sphere.
 

Static Public Attributes

static constexpr index_t N
 The dimension of this object.
 

Related Symbols

(Note that these are not member symbols.)

template<typename T>
using Circle = Sphere<T,2>
 A 2D circle.
 

Detailed Description

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

An N-dimensional circle, sphere, or hypersphere with a filled interior.

Circle<T> is a template alias for Sphere<T,2>.

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

◆ Sphere() [1/3]

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

Construct a sphere at the origin with radius 1.

◆ Sphere() [2/3]

template<typename T, index_t N>
Sphere ( T r)
inlineconstexpr

Construct a sphere with center at the origin, having radius r.

Parameters
rRadius of spehre.

◆ Sphere() [3/3]

template<typename T, index_t N>
Sphere ( const point_t & c,
T r )
inlineconstexpr

Construct a sphere with center at the point c, having radius r.

Parameters
cCenter of sphere.
rRadius of spehre.

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.

◆ intersects() [1/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.

◆ intersects() [2/2]

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

Sphere-sphere intersection test.

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

◆ measure_boundary()

template<typename T, index_t N>
T measure_boundary ( ) const
inline

Measure the boundary of the shape.

If the sphere is 2D (a circle), this is the circumference of the circle. If the sphere is 3D (a sphere), this is the surface area of the sphere. In higher dimensions, this is the volume or hypervolume of the boundary.

◆ measure_interior()

template<typename T, index_t N>
T measure_interior ( ) const
inline

Measure the interior (volume) of the shape.

If the sphere is 2D (a disk), this is the area of the disk. If the sphere is 3D (a ball), this is the volume of the ball. In higher dimensions, this is the hypervolume.

◆ project()

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.


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