25#ifndef DUMUX_MULTIDOMAIN_EMBEDDED_CIRCLEPOINTS_HH
26#define DUMUX_MULTIDOMAIN_EMBEDDED_CIRCLEPOINTS_HH
31#include <dune/common/exceptions.hh>
49template<
class GlobalPosition,
class Scalar>
51 const std::vector<Scalar>& sincos,
52 const GlobalPosition& center,
53 const GlobalPosition&
normal,
56 assert(sincos.size() % 2 == 0 &&
"Sample angles have to be pairs of sin/cos so size needs to be even.");
57 static_assert(GlobalPosition::dimension == 3,
"Only implemented for world dimension 3");
60 const std::size_t numPoints = sincos.size()/2;
61 points.resize(numPoints);
72 tangent *= radius/tangent.two_norm();
75 for (std::size_t i = 0; i < numPoints; ++i)
77 points[i] = GlobalPosition({u[0]*sincos[2*i+1] + tangent[0]*sincos[2*i] + center[0],
78 u[1]*sincos[2*i+1] + tangent[1]*sincos[2*i] + center[1],
79 u[2]*sincos[2*i+1] + tangent[2]*sincos[2*i] + center[2]});
91template<
class GlobalPosition,
class Scalar>
92std::vector<GlobalPosition>
circlePoints(
const GlobalPosition& center,
93 const GlobalPosition&
normal,
95 const std::size_t numPoints = 20)
97 std::vector<GlobalPosition> points;
100 std::vector<Scalar> sincos(2*numPoints);
102 for (std::size_t i = 0; i < numPoints; ++i)
104 using std::sin;
using std::cos;
105 sincos[2*i] = sin(t);
106 sincos[2*i + 1] = cos(t);
107 t += 2*M_PI/numPoints;
108 if(t > 2*M_PI) t -= 2*M_PI;
Define some often used mathematical functions.
Vector normal(const Vector &v)
Create a vector normal to the given one (v is expected to be non-zero)
Definition: geometry/normal.hh:36
Vector unitNormal(const Vector &v)
Create a vector normal to the given one (v is expected to be non-zero)
Definition: geometry/normal.hh:68
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:640
void circlePoints(std::vector< GlobalPosition > &points, const std::vector< Scalar > &sincos, const GlobalPosition ¢er, const GlobalPosition &normal, const Scalar radius)
Definition: circlepoints.hh:50
Definition: circlepoints.hh:36
Helper functions for normals.