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 >:
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
point_t clip (point_t p) const
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 Rect< T, N > &rect) const
template<ConvexObject Shape>
bool intersects (const Shape &other) 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.
radius
 Radius of the sphere.

Static Public Attributes

static constexpr index_t N
 The dimension of this object.

(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

◆ intersects()

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: