22#ifndef DUMUX_GEOMETRY_BOUNDINGSPHERE_HH
23#define DUMUX_GEOMETRY_BOUNDINGSPHERE_HH
38template<
class ConvexGeometry>
39static inline Sphere<typename ConvexGeometry::ctype, ConvexGeometry::coorddimension>
42 constexpr int dimWorld = ConvexGeometry::coorddimension;
43 assert(geometry.corners() >= 1);
45 auto corner = geometry.corner(0);
46 auto xMin = corner, xMax = corner;
47 using std::max;
using std::min;
50 for (std::size_t i = 1; i < geometry.corners(); ++i)
52 corner = geometry.corner(i);
53 for (std::size_t dimIdx = 0; dimIdx < dimWorld; ++dimIdx)
55 xMin[dimIdx] = min(xMin[dimIdx], corner[dimIdx]);
56 xMax[dimIdx] = max(xMax[dimIdx], corner[dimIdx]);
60 auto center = 0.5*xMax + xMin;
61 auto radius = (center-xMax).two_norm();
62 return { std::move(center), std::move(radius) };
66template<
class Scalar,
int dim>
69 const std::vector<Dune::FieldVector<Scalar, dim>>&
points_;
87template<
class Scalar,
int dim>
88static inline Sphere<Scalar, dim>
A function to compute bounding spheres of points clouds or convex polytopes.
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:40
Definition: boundingsphere.hh:68
static constexpr int coorddimension
Definition: boundingsphere.hh:73
const std::vector< Dune::FieldVector< Scalar, dim > > & points_
Definition: boundingsphere.hh:69
const auto & corner(std::size_t i) const
Definition: boundingsphere.hh:77
Scalar ctype
Definition: boundingsphere.hh:74
auto corners() const
Definition: boundingsphere.hh:76
PointsToGeometryWrapper(const std::vector< Dune::FieldVector< Scalar, dim > > &points)
Definition: boundingsphere.hh:70