geomc 1.0
A c++ linear algebra template library
|
The surface of a sphere within a certain angle from its pole. More...
#include <geomc/shape/SphericalCap.h>
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, N > | bounds () 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. | |
T | 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. | |
T | sdf (point_t p) const |
Signed distance function. | |
Static Public Member Functions | |
static constexpr bool | admits_cusps () |
Public Attributes | |
T | 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. | |
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>.
|
inherited |
The type of a point in this object's space.
An N-vector of T if N > 1, otherwise a T.
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.
|
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 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.
|
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.
|
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.