// expand an axis-aligned bounding box to include a sphere KOKKOS_INLINE_FUNCTION void expand( Box &box, Sphere const &sphere ) { using KokkosExt::max; using KokkosExt::min; for ( int d = 0; d < 3; ++d ) { box.minCorner()[d] = min( box.minCorner()[d], sphere.centroid()[d] - sphere.radius() ); box.maxCorner()[d] = max( box.maxCorner()[d], sphere.centroid()[d] + sphere.radius() ); } }
KOKKOS_INLINE_FUNCTION bool isValid( Sphere const &s ) { using KokkosExt::isFinite; return isValid( s.centroid() ) && isFinite( s.radius() ) && ( s.radius() >= 0. ); }
KOKKOS_INLINE_FUNCTION bool equals( Sphere const &l, Sphere const &r ) { return equals( l.centroid(), r.centroid() ) && l.radius() == r.radius(); }
KOKKOS_INLINE_FUNCTION Point returnCentroid( Sphere const &sphere ) { return sphere.centroid(); }
// check if a sphere intersects with an axis-aligned bounding box KOKKOS_INLINE_FUNCTION bool intersects( Sphere const &sphere, Box const &box ) { return distance( sphere.centroid(), box ) <= sphere.radius(); }
// distance point-sphere KOKKOS_INLINE_FUNCTION double distance( Point const &point, Sphere const &sphere ) { using KokkosExt::max; return max( distance( point, sphere.centroid() ) - sphere.radius(), 0. ); }