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

A N-dimensional circle, sphere, or hypersphere. 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, Derived > SdfEvaluable< T, N, Derived >

Public Types

typedef ptype::point_t point_t
 
typedef T elem_t
 The coordinate type of this shape.
 

Public Member Functions

constexpr Sphere ()
 
constexpr Sphere (T r)
 
constexpr Sphere (const point_t &c, T r)
 
Rect< T, Nbounds () const
 
bool contains (point_t p) const
 Shape-point intersection test.
 
bool intersects (Sphere s) const
 
point_t convex_support (point_t d) const
 
sdf (point_t p) const
 Signed distance function.
 
point_t project (point_t p) const
 
point_t normal (point_t p) const
 Outward-facing direction.
 
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. More...
 
Vec< T, Nclip (Vec< T, N > p) const
 Nearest point on the interior of the shape. More...
 

Public Attributes

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

Static Public Attributes

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

Detailed Description

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

A N-dimensional circle, sphere, or hypersphere.

Constructor & Destructor Documentation

◆ Sphere() [1/3]

constexpr Sphere ( )
inlineconstexpr

Construct a sphere at the origin with radius 1.

◆ Sphere() [2/3]

constexpr Sphere ( r)
inlineconstexpr

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

Parameters
rRadius of spehre.

◆ Sphere() [3/3]

constexpr Sphere ( const point_t c,
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]

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.

◆ project()

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: