12#ifndef DUMUX_GEOMETRY_BOUNDINGSPHERE_HH
13#define DUMUX_GEOMETRY_BOUNDINGSPHERE_HH
28template<
class ConvexGeometry>
29static inline Sphere<typename ConvexGeometry::ctype, ConvexGeometry::coorddimension>
32 constexpr int dimWorld = ConvexGeometry::coorddimension;
33 assert(geometry.corners() >= 1);
35 auto corner = geometry.corner(0);
36 auto xMin = corner, xMax = corner;
37 using std::max;
using std::min;
40 for (std::size_t i = 1; i < geometry.corners(); ++i)
42 corner = geometry.corner(i);
43 for (std::size_t dimIdx = 0; dimIdx < dimWorld; ++dimIdx)
45 xMin[dimIdx] = min(xMin[dimIdx], corner[dimIdx]);
46 xMax[dimIdx] = max(xMax[dimIdx], corner[dimIdx]);
50 auto center = 0.5*xMax + xMin;
51 auto radius = (
center-xMax).two_norm();
52 return { std::move(
center), std::move(radius) };
56template<
class Scalar,
int dim>
59 const std::vector<Dune::FieldVector<Scalar, dim>>&
points_;
77template<
class Scalar,
int dim>
78static inline Sphere<Scalar, dim>
static Sphere< typename ConvexGeometry::ctype, ConvexGeometry::coorddimension > boundingSphere(const ConvexGeometry &geometry)
Computes a bounding sphere of a convex polytope geometry (Dune::Geometry interface)
Definition: boundingsphere.hh:30
Corners::value_type center(const Corners &corners)
The center of a given list of corners.
Definition: center.hh:24
A function to compute bounding spheres of points clouds or convex polytopes.
Definition: boundingsphere.hh:58
static constexpr int coorddimension
Definition: boundingsphere.hh:63
const std::vector< Dune::FieldVector< Scalar, dim > > & points_
Definition: boundingsphere.hh:59
const auto & corner(std::size_t i) const
Definition: boundingsphere.hh:67
Scalar ctype
Definition: boundingsphere.hh:64
auto corners() const
Definition: boundingsphere.hh:66
PointsToGeometryWrapper(const std::vector< Dune::FieldVector< Scalar, dim > > &points)
Definition: boundingsphere.hh:60