3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
circumsphere.hh
Go to the documentation of this file.
1/*****************************************************************************
2 * See the file COPYING for full copying permissions. *
3 * *
4 * This program is free software: you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation, either version 3 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
16 *****************************************************************************/
24#ifndef DUMUX_GEOMETRY_CIRCUMSPHERE_HH
25#define DUMUX_GEOMETRY_CIRCUMSPHERE_HH
26
27#include <type_traits>
28#include <dumux/common/math.hh>
30
31namespace Dumux {
32
38template<class Point>
39static inline Sphere<typename Point::value_type, Point::dimension>
40circumSphereOfTriangle(const Point& a, const Point& b, const Point& c)
41{
42 const auto ac = c - a;
43 const auto ab = b - a;
44 const auto n = crossProduct(ab, ac);
45 const auto distCenterToA = (crossProduct(n, ab)*ac.two_norm2() + crossProduct(ac, n)*ab.two_norm2()) / (2.0*n.two_norm2());
46
47 return { a + distCenterToA, distCenterToA.two_norm() };
48}
49
54template<class Geometry, typename std::enable_if_t<Geometry::mydimension == 2, int> = 0>
55static inline Sphere<typename Geometry::ctype, Geometry::coorddimension>
56circumSphereOfTriangle(const Geometry& triangle)
57{
58 assert(triangle.corners() == 3 && "Geometry is not a triangle.");
59 return circumSphereOfTriangle(triangle.corner(0), triangle.corner(1), triangle.corner(2));
60}
61
62} // end namespace Dumux
63
64#endif
Define some often used mathematical functions.
A function to compute bounding spheres of points clouds or convex polytopes.
static Sphere< typename Point::value_type, Point::dimension > circumSphereOfTriangle(const Point &a, const Point &b, const Point &c)
Computes the circumsphere of a triangle.
Definition: circumsphere.hh:40
Dune::FieldVector< Scalar, 3 > crossProduct(const Dune::FieldVector< Scalar, 3 > &vec1, const Dune::FieldVector< Scalar, 3 > &vec2)
Cross product of two vectors in three-dimensional Euclidean space.
Definition: math.hh:654
Definition: adapt.hh:29