20 #ifndef ANTKEEPER_GEOM_PRIMITIVES_HYPERSPHERE_HPP
21 #define ANTKEEPER_GEOM_PRIMITIVES_HYPERSPHERE_HPP
27 namespace primitives {
35 template <
class T, std::
size_t N>
68 const T containment_radius =
radius - other.radius;
69 if (containment_radius < T{0})
99 const T intersection_radius =
radius + other.radius;
114 template <std::
size_t M>
115 [[nodiscard]]
static constexpr T
volume(T r) noexcept
117 return (math::two_pi<T> /
static_cast<T
>(M)) * r * r *
volume<M - 2>(r);
121 [[nodiscard]]
static constexpr T volume<1>(T r) noexcept
127 [[nodiscard]]
static constexpr T volume<0>(T r) noexcept
134 [[nodiscard]]
inline constexpr T
volume() const noexcept
142 using namespace primitives;
constexpr T sqr_distance(const vector< T, N > &p0, const vector< T, N > &p1) noexcept
Calculates the square distance between two points.
vector< T, N > sqrt(const vector< T, N > &x)
Takes the square root of each element.
vector_type center
Hypersphere center.
constexpr bool contains(const hypersphere &other) const noexcept
Tests whether another hypersphere is contained within this hypersphere.
constexpr bool contains(const vector_type &point) const noexcept
Tests whether a point is contained within this hypersphere.
constexpr T volume() const noexcept
Calculates the volume of the hypersphere.
T radius
Hypersphere radius.
T distance(const vector_type &point) const noexcept
Calculates the signed distance from the hypersphere to a point.
constexpr bool intersects(const hypersphere &other) const noexcept
Tests whether another hypersphere intersects this hypersphere.