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

The surface of a sphere within a certain angle from its pole. More...

#include <geomc/shape/SphericalCap.h>

Inheritance diagram for SphericalCap< 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

 SphericalCap (T radians)
 Construct a spherical cap with the given half-angle.
 
Rect< T, Nbounds () const
 Axis aligned bounding box.
 
point_t clip (point_t p) const
 Clamp the coordinates of p to lie within this shape.
 
constexpr bool contains (point_t p) const
 Point containment test. Always false, because the shape is a surface.
 
Rect< T, 1 > intersect (const Ray< T, N > &ray) const
 Intersect the cap with a ray.
 
bool is_inside_angle (point_t p) const
 Test whether the point p is inside the cap's angle.
 
measure_boundary () const
 Measure the boundary (surface area) of the shape.
 
point_t normal (point_t p) const
 Outward-facing direction.
 
bool operator== (const SphericalCap &other) const
 Shape equality.
 
point_t project (point_t p) const
 Project the point p orthogonally onto the surface of the cap.
 
sdf (point_t p) const
 Signed distance function.
 

Static Public Member Functions

static constexpr bool admits_cusps ()
 

Public Attributes

half_angle_radians
 Angle between the polar axis and the edge of the cap, in radians.
 

Static Public Attributes

static constexpr index_t N
 The dimension of this object.
 

Detailed Description

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

The surface of a sphere within a certain angle from its pole.

The cap is defined by a half-angle, which is the angle between the pole and the edge of the cap. The pole is the final axis in N-dimensional space.

The cap is a surface, and has no interior. It is concave towards the origin.

In 2D, the cap is an arc centered on the Y+ axis. In 3D, it's a cap centered on Z+.

It is valid for the cap to extend beyond the equator. The half angle is canonically between 0 and π.

To orient or scale the cap, wrap it with a Similar<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.

Member Function Documentation

◆ clip()

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

Clamp the coordinates of p to lie within this shape.

This is the same as project(), because the shape is a surface and has no interior.

◆ contains()

template<typename T, index_t N>
bool contains ( point_t p) const
inlineconstexpr

Point containment test. Always false, because the shape is a surface.

This is implemented to conform to the SdfObject concept, since a signed distance function trivially implies the ability to test for point containment. The signed distance function never returns a value less than zero, so this method always returns false.

◆ intersect()

template<typename T, index_t N>
Rect< T, 1 > intersect ( const Ray< T, N > & ray) const
inline

Intersect the cap with a ray.

The ray may intersect the cap at 0, 1, or 2 points. In the case of 2 points, the ray parameters will be the two endpoints of the interval. In the case of 1 point, the endpoints of the interval will be identical. In the case of 0 points, the interval is empty.

Note that, unlike with other shapes, the interval between the two endpoints is not part of the cap.

◆ is_inside_angle()

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

Test whether the point p is inside the cap's angle.

Returns true if p orthogonally projects to the cap's surface; false if it projects to the cap's edge.

◆ measure_boundary()

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

Measure the boundary (surface area) of the shape.

For a 2D spherical cap, this is the arc length; the same as its full angle. For 3D, this is the area of the cap; the same as its solid angle.

Higher dimensions are not yet available, but may be provided in the future.


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