23#ifndef VCL_SPACE_CORE_SPHERE_H
24#define VCL_SPACE_CORE_SPHERE_H
30template<
typename Scalar>
37 using ScalarType = Scalar;
44 mCenter(center), mRadius(radius)
53 const Scalar& radius()
const {
return mRadius; }
55 Scalar& radius() {
return mRadius; }
60 if constexpr (std::is_same_v<Scalar, S>) {
68 Scalar diameter()
const {
return 2 * mRadius; }
70 Scalar circumference()
const {
return 2 *
M_PI * mRadius; }
72 Scalar surfaceArea()
const {
return 4 *
M_PI * std::pow(mRadius, 2); }
74 Scalar volume()
const {
return (4.0 / 3) *
M_PI * std::pow(mRadius, 3); }
78 return mCenter.dist(
p) <= mRadius;
92 if (mCenter[
i] <
b.
min()[
i])
94 else if (mCenter[
i] >
b.
max()[
i])
97 if (
dmin <= std::pow(mRadius, 2))
106using Spheref = Sphere<float>;
107using Sphered = Sphere<double>;
111template<Po
int3Concept P,
typename T>
112Sphere(P, T) -> Sphere<typename P::ScalarType>;
128 std::remove_cvref_t<T>,
129 Sphere<typename RemoveRef<T>::ScalarType>>;
A class representing a box in N-dimensional space.
Definition box.h:46
PointT & max()
Returns a reference to the maximum point of the box.
Definition box.h:104
PointT & min()
Returns a reference to the minimum point of the box.
Definition box.h:90
bool intersects(const Box3< Scalar > &b) const
Checks if a sphere intersects with a Box.
Definition sphere.h:87
A concept representing a Sphere.
Definition sphere.h:127