23#ifndef DUMUX_GEOMETRY_INTERSECTION_HH
24#define DUMUX_GEOMETRY_INTERSECTION_HH
28#include <dune/common/exceptions.hh>
29#include <dune/common/promotiontraits.hh>
30#include <dune/geometry/multilineargeometry.hh>
38namespace IntersectionPolicy {
41template<
class ct,
int dw>
45 using Point = Dune::FieldVector<ctype, dw>;
53template<
class ct,
int dw>
57 using Point = Dune::FieldVector<ctype, dw>;
66template<
class ct,
int dw>
70 using Point = Dune::FieldVector<ctype, dw>;
79template<
class ct,
int dw>
83 using Point = Dune::FieldVector<ctype, dw>;
92template<
class Geometry1,
class Geometry2>
95 static constexpr int dimworld = Geometry1::coorddimension;
96 static constexpr int isDim = std::min(
int(Geometry1::mydimension),
int(Geometry2::mydimension) );
97 static_assert(dimworld == int(Geometry2::coorddimension),
98 "Geometries must have the same coordinate dimension!");
99 static_assert(int(Geometry1::mydimension) <= 3 && int(Geometry2::mydimension) <= 3,
100 "Geometries must have dimension 3 or less.");
101 using ctype =
typename Dune::PromotionTraits<typename Geometry1::ctype, typename Geometry2::ctype>::PromotedType;
103 using DefaultPolicies = std::tuple<PointPolicy<ctype, dimworld>,
108 using type = std::tuple_element_t<isDim, DefaultPolicies>;
112template<
class Geometry1,
class Geometry2>
132template<
class Geo1,
class Geo2,
class ctype,
133 class GetFacetCornerIndices,
class ComputeNormalFunction >
135 ctype& tfirst, ctype& tlast,
136 const GetFacetCornerIndices& getFacetCornerIndices,
137 const ComputeNormalFunction& computeNormal)
139 static_assert(int(Geo2::mydimension) == 1,
"Geometry2 must be a segment");
140 static_assert(int(Geo1::mydimension) > int(Geo2::mydimension),
141 "Dimension of Geometry1 must be higher than that of Geometry2");
143 const auto a = geo2.corner(0);
144 const auto b = geo2.corner(1);
145 const auto d = b - a;
153 const auto facets = getFacetCornerIndices(geo1);
154 for (
const auto& f : facets)
156 const auto n = computeNormal(f);
158 const auto c0 = geo1.corner(f[0]);
159 const ctype denom = n*d;
160 const ctype dist = n*(a-c0);
163 const auto edge1 = geo1.corner(f[1]) - geo1.corner(f[0]);
164 const ctype eps = baseEps*edge1.two_norm();
169 if (abs(denom) < eps)
176 const ctype t = -dist / denom;
192 if (tfirst > tlast - baseEps)
210<
class Geometry1,
class Geometry2,
211 class Policy = IntersectionPolicy::DefaultPolicy<Geometry1, Geometry2>,
212 int dimworld = Geometry1::coorddimension,
213 int dim1 = Geometry1::mydimension,
214 int dim2 = Geometry2::mydimension>
217 static constexpr int dimWorld = Policy::dimWorld;
220 using ctype =
typename Policy::ctype;
221 using Point =
typename Policy::Point;
227 static_assert(dimworld == Geometry2::coorddimension,
"Can only intersect geometries of same coordinate dimension");
228 DUNE_THROW(Dune::NotImplemented,
"Geometry intersection detection with intersection computation not implemented for dimworld = "
229 << dimworld <<
", dim1 = " << dim1 <<
", dim2 = " << dim2);
237template <
class Geometry1,
class Geometry2,
class Policy>
240 enum { dimworld = 2 };
245 static constexpr typename Policy::ctype eps_ = 1.5e-7;
248 using ctype =
typename Policy::ctype;
249 using Point =
typename Policy::Point;
258 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 0,
int> = 0>
261 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
263 const auto v1 = geo1.corner(1) - geo1.corner(0);
264 const auto v2 = geo2.corner(1) - geo2.corner(0);
265 const auto ac = geo2.corner(0) - geo1.corner(0);
267 auto n2 =
Point({-1.0*v2[1], v2[0]});
271 const auto dist12 = n2*ac;
277 const auto v1Norm2 = v1.two_norm2();
278 const auto eps = eps_*sqrt(v1Norm2);
279 const auto eps2 = eps_*v1Norm2;
281 const auto sp = n2*v1;
284 if (abs(dist12) > eps)
290 if ( ac.two_norm2() < eps2 )
293 if ( (geo2.corner(1) - geo1.corner(1)).two_norm2() < eps2 )
298 if ( (geo2.corner(1) - geo1.corner(0)).two_norm2() < eps2 )
301 if ( (geo2.corner(0) - geo1.corner(1)).two_norm2() < eps2 )
310 const auto t1 = dist12 / sp;
313 if (t1 < -1.0*eps_ || t1 > 1.0 + eps_)
317 auto isPoint = geo1.global(t1);
320 const auto c = geo2.corner(0);
321 const auto d = geo2.corner(1);
323 using std::min;
using std::max;
324 std::array<ctype, 4> bBox({ min(c[0], d[0]), min(c[1], d[1]), max(c[0], d[0]), max(c[1], d[1]) });
341 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 1,
int> = 0>
344 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
346 const auto& a = geo1.corner(0);
347 const auto& b = geo1.corner(1);
348 const auto ab = b - a;
350 const auto& p = geo2.corner(0);
351 const auto& q = geo2.corner(1);
352 const auto pq = q - p;
353 Dune::FieldVector<ctype, dimworld> n2{-pq[1], pq[0]};
356 const auto abNorm2 = ab.two_norm2();
357 const auto pqNorm2 = pq.two_norm2();
358 const auto eps2 = eps_*max(abNorm2, pqNorm2);
362 if (abs(n2*ab) > eps2)
366 const auto ap = p - a;
367 if (abs(ap*n2) > eps2)
372 auto t2 = ab*(q - a);
379 t1 = clamp(t1, 0.0, abNorm2);
380 t2 = clamp(t2, 0.0, abNorm2);
382 if (abs(t2-t1) < eps2)
394template <
class Geometry1,
class Geometry2,
class Policy>
397 enum { dimworld = 2 };
402 using ctype =
typename Policy::ctype;
403 using Point =
typename Policy::Point;
407 static constexpr ctype eps_ = 1.5e-7;
417 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 1,
int> = 0>
420 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
423 if (intersect_(geo1, geo2, tfirst, tlast))
441 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 0,
int> = 0>
444 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
447 if (!intersect_(geo1, geo2, tfirst, tlast))
451 if ( tfirst > tlast - eps_ )
465 static bool intersect_(
const Geometry1& geo1,
const Geometry2& geo2,
ctype& tfirst,
ctype& tlast)
468 auto getFacetCorners = [] (
const Geometry1& geo1)
470 std::vector< std::array<int, 2> > facetCorners;
471 switch (geo1.corners())
474 facetCorners = {{0, 2}, {3, 1}, {1, 0}, {2, 3}};
477 facetCorners = {{1, 0}, {0, 2}, {2, 1}};
480 DUNE_THROW(Dune::NotImplemented,
"Collision of segment and geometry of type "
481 << geo1.type() <<
" with "<< geo1.corners() <<
" corners.");
488 const auto center1 = geo1.center();
489 auto computeNormal = [&geo1, ¢er1] (
const std::array<int, 2>& facetCorners)
491 const auto c0 = geo1.corner(facetCorners[0]);
492 const auto c1 = geo1.corner(facetCorners[1]);
493 const auto edge = c1 - c0;
495 Dune::FieldVector<ctype, dimworld> n({-1.0*edge[1], edge[0]});
500 if ( n*(center1-c0) > 0.0 )
514template <
class Geometry1,
class Geometry2,
class Policy>
528 template<
class P = Policy>
539template <
class Geometry1,
class Geometry2,
class Policy>
542 enum { dimworld = 2 };
547 using ctype =
typename Policy::ctype;
548 using Point =
typename Policy::Point;
552 static constexpr ctype eps_ = 1.5e-7;
567 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 2,
int> = 0>
570 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
573 std::vector<Point> points; points.reserve(6);
576 for (
int i = 0; i < geo1.corners(); ++i)
578 points.emplace_back(geo1.corner(i));
580 const auto numPoints1 = points.size();
581 if (numPoints1 != geo1.corners())
584 for (
int i = 0; i < geo2.corners(); ++i)
586 points.emplace_back(geo2.corner(i));
591 if (points.size() - numPoints1 != geo2.corners())
593 const auto refElement1 = referenceElement(geo1);
594 const auto refElement2 = referenceElement(geo2);
597 using SegGeometry = Dune::MultiLinearGeometry<ctype, 1, dimworld>;
599 for (
int i = 0; i < refElement1.size(dim1-1); ++i)
601 const auto localEdgeGeom1 = refElement1.template geometry<dim1-1>(i);
603 std::vector<Point>( {geo1.global(localEdgeGeom1.corner(0)),
604 geo1.global(localEdgeGeom1.corner(1))} ));
606 for (
int j = 0; j < refElement2.size(dim2-1); ++j)
608 const auto localEdgeGeom2 = refElement2.template geometry<dim2-1>(j);
610 std::vector<Point>( {geo2.global(localEdgeGeom2.corner(0)),
611 geo2.global(localEdgeGeom2.corner(1))} ));
614 typename EdgeTest::Intersection edgeIntersection;
615 if (EdgeTest::intersection(edge1, edge2, edgeIntersection))
616 points.emplace_back(edgeIntersection);
626 const auto eps = (geo1.corner(0) - geo1.corner(1)).two_norm()*eps_;
627 std::sort(points.begin(), points.end(), [&eps](
const auto& a,
const auto& b) ->
bool
630 return (abs(a[0]-b[0]) > eps ? a[0] < b[0] : a[1] < b[1]);
633 auto removeIt = std::unique(points.begin(), points.end(), [&eps](
const auto& a,
const auto&b)
635 return (b-a).two_norm() < eps;
638 points.erase(removeIt, points.end());
641 if (points.size() < 3)
657 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 1,
int> = 0>
660 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
661 DUNE_THROW(Dune::NotImplemented,
"Polygon-polygon intersection detection for segment-like intersections");
671 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 0,
int> = 0>
674 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
675 DUNE_THROW(Dune::NotImplemented,
"Polygon-polygon intersection detection for touching points");
683template <
class Geometry1,
class Geometry2,
class Policy>
686 enum { dimworld = 3 };
691 using ctype =
typename Policy::ctype;
692 using Point =
typename Policy::Point;
696 static constexpr ctype eps_ = 1.5e-7;
710 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 1,
int> = 0>
713 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
716 if (intersect_(geo1, geo2, tfirst, tlast))
738 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 0,
int> = 0>
741 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
744 if (intersect_(geo1, geo2, tfirst, tlast))
748 if ( abs(tfirst - tlast) < eps_ )
762 static bool intersect_(
const Geometry1& geo1,
const Geometry2& geo2,
ctype& tfirst,
ctype& tlast)
765 auto getFacetCorners = [] (
const Geometry1& geo1)
767 std::vector< std::vector<int> > facetCorners;
769 switch (geo1.corners())
773 facetCorners = {{2, 0, 6, 4}, {1, 3, 5, 7}, {0, 1, 4, 5},
774 {3, 2, 7, 6}, {1, 0, 3, 2}, {4, 5, 6, 7}};
777 facetCorners = {{1, 0, 2}, {0, 1, 3}, {0, 3, 2}, {1, 2, 3}};
780 DUNE_THROW(Dune::NotImplemented,
"Collision of segment and geometry of type "
781 << geo1.type() <<
", "<< geo1.corners() <<
" corners.");
788 auto computeNormal = [&geo1] (
const std::vector<int>& facetCorners)
790 const auto v0 = geo1.corner(facetCorners[1]) - geo1.corner(facetCorners[0]);
791 const auto v1 = geo1.corner(facetCorners[2]) - geo1.corner(facetCorners[0]);
807template <
class Geometry1,
class Geometry2,
class Policy>
820 template<
class P = Policy>
831template <
class Geometry1,
class Geometry2,
class Policy>
834 enum { dimworld = 3 };
839 using ctype =
typename Policy::ctype;
840 using Point =
typename Policy::Point;
844 static constexpr ctype eps_ = 1.5e-7;
861 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 2,
int> = 0>
864 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
867 std::vector<Point> points; points.reserve(10);
870 for (
int i = 0; i < geo1.corners(); ++i)
872 points.emplace_back(geo1.corner(i));
875 for (
int i = 0; i < geo2.corners(); ++i)
877 points.emplace_back(geo2.corner(i));
880 using PolyhedronFaceGeometry = Dune::MultiLinearGeometry<ctype, 2, dimworld>;
881 using SegGeometry = Dune::MultiLinearGeometry<ctype, 1, dimworld>;
883 const auto refElement1 = referenceElement(geo1);
884 const auto refElement2 = referenceElement(geo2);
890 for (
int i = 0; i < refElement1.size(dim1-1); ++i)
892 const auto localEdgeGeom = refElement1.template geometry<dim1-1>(i);
893 const auto p = geo1.global(localEdgeGeom.corner(0));
894 const auto q = geo1.global(localEdgeGeom.corner(1));
898 typename PolySegTest::Intersection polySegIntersection;
899 if (PolySegTest::intersection(geo2, segGeo, polySegIntersection))
900 points.emplace_back(polySegIntersection);
904 for (
int i = 0; i < refElement1.size(1); ++i)
906 const auto faceGeo = [&]()
908 const auto localFaceGeo = refElement1.template geometry<1>(i);
909 if (localFaceGeo.corners() == 4)
911 const auto a = geo1.global(localFaceGeo.corner(0));
912 const auto b = geo1.global(localFaceGeo.corner(1));
913 const auto c = geo1.global(localFaceGeo.corner(2));
914 const auto d = geo1.global(localFaceGeo.corner(3));
916 return PolyhedronFaceGeometry(Dune::GeometryTypes::cube(2), std::vector<Point>{a, b, c, d});
920 const auto a = geo1.global(localFaceGeo.corner(0));
921 const auto b = geo1.global(localFaceGeo.corner(1));
922 const auto c = geo1.global(localFaceGeo.corner(2));
924 return PolyhedronFaceGeometry(Dune::GeometryTypes::simplex(2), std::vector<Point>{a, b, c});
928 for (
int j = 0; j < refElement2.size(1); ++j)
930 const auto localEdgeGeom = refElement2.template geometry<1>(j);
931 const auto p = geo2.global(localEdgeGeom.corner(0));
932 const auto q = geo2.global(localEdgeGeom.corner(1));
937 typename PolySegTest::Intersection polySegIntersection;
938 if (PolySegTest::intersection(faceGeo, segGeo, polySegIntersection))
939 points.emplace_back(polySegIntersection);
944 if (points.empty())
return false;
947 const auto eps = (geo1.corner(0) - geo1.corner(1)).two_norm()*eps_;
948 std::sort(points.begin(), points.end(), [&eps](
const auto& a,
const auto& b) ->
bool
951 return (abs(a[0]-b[0]) > eps ? a[0] < b[0] : (abs(a[1]-b[1]) > eps ? a[1] < b[1] : (a[2] < b[2])));
954 auto removeIt = std::unique(points.begin(), points.end(), [&eps](
const auto& a,
const auto&b)
956 return (b-a).two_norm() < eps;
959 points.erase(removeIt, points.end());
962 if (points.size() < 3)
return false;
985 template<
class P = Policy, std::enable_if_t<P::dimIntersection != 2,
int> = 0>
988 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
989 DUNE_THROW(Dune::NotImplemented,
"Polyhedron-polygon intersection detection only implemented for polygon-like intersections");
997template <
class Geometry1,
class Geometry2,
class Policy>
1010 template<
class P = Policy>
1021template <
class Geometry1,
class Geometry2,
class Policy>
1024 enum { dimworld = 3 };
1034 static constexpr ctype eps_ = 1.5e-7;
1046 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 1,
int> = 0>
1049 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
1051 ctype tfirst, tlast;
1052 if (intersect_(geo1, geo2, tfirst, tlast))
1072 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 0,
int> = 0>
1075 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
1077 const auto p = geo2.corner(0);
1078 const auto q = geo2.corner(1);
1080 const auto a = geo1.corner(0);
1081 const auto b = geo1.corner(1);
1082 const auto c = geo1.corner(2);
1084 if (geo1.corners() == 3)
1085 return intersect_<Policy>(a, b, c, p, q, is);
1087 else if (geo1.corners() == 4)
1090 bool hasSegment1, hasSegment2;
1092 const auto d = geo1.corner(3);
1093 const bool intersects1 = intersect_<Policy>(a, b, d, p, q, is1, hasSegment1);
1094 const bool intersects2 = intersect_<Policy>(a, d, c, p, q, is2, hasSegment2);
1096 if (hasSegment1 || hasSegment2)
1099 if (intersects1) { is = is1;
return true; }
1100 if (intersects2) { is = is2;
return true; }
1106 DUNE_THROW(Dune::NotImplemented,
"Collision of segment and geometry of type "
1107 << geo1.type() <<
", "<< geo1.corners() <<
" corners.");
1114 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 1,
int> = 0>
1115 static bool intersect_(
const Geometry1& geo1,
const Geometry2& geo2,
ctype& tfirst,
ctype& tlast)
1118 auto getFacetCorners = [] (
const Geometry1& geo1)
1120 std::vector< std::array<int, 2> > facetCorners;
1121 switch (geo1.corners())
1124 facetCorners = {{0, 2}, {3, 1}, {1, 0}, {2, 3}};
1127 facetCorners = {{1, 0}, {0, 2}, {2, 1}};
1130 DUNE_THROW(Dune::NotImplemented,
"Collision of segment and geometry of type "
1131 << geo1.type() <<
" with "<< geo1.corners() <<
" corners.");
1134 return facetCorners;
1137 const auto center1 = geo1.center();
1138 const auto normal1 =
crossProduct(geo1.corner(1) - geo1.corner(0),
1139 geo1.corner(2) - geo1.corner(0));
1142 auto computeNormal = [¢er1, &normal1, &geo1] (
const std::array<int, 2>& facetCorners)
1144 const auto c0 = geo1.corner(facetCorners[0]);
1145 const auto c1 = geo1.corner(facetCorners[1]);
1146 const auto edge = c1 - c0;
1148 Dune::FieldVector<ctype, dimworld> n =
crossProduct(edge, normal1);
1153 if ( n*(center1-c0) > 0.0 )
1165 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 0,
int> = 0>
1166 static bool intersect_(
const Point& a,
const Point& b,
const Point& c,
1171 return intersect_(a, b, c, p, q, is, hasSegment);
1178 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 0,
int> = 0>
1179 static bool intersect_(
const Point& a,
const Point& b,
const Point& c,
1183 hasSegmentIs =
false;
1185 const auto ab = b - a;
1186 const auto ac = c - a;
1187 const auto qp = p - q;
1194 const auto denom =
normal*qp;
1195 const auto abnorm2 = ab.two_norm2();
1196 const auto eps = eps_*abnorm2*qp.two_norm();
1198 if (abs(denom) < eps)
1200 const auto pa = a - p;
1201 const auto denom2 =
normal*pa;
1202 if (abs(denom2) > eps_*pa.two_norm()*abnorm2)
1207 using SegmentPolicy =
typename IntersectionPolicy::SegmentPolicy<ctype, dimworld>;
1208 using Triangle = Dune::AffineGeometry<ctype, 2, dimworld>;
1209 using Segment = Dune::AffineGeometry<ctype, 1, dimworld>;
1210 using SegmentIntersectionAlgorithm = GeometryIntersection<Triangle, Segment, SegmentPolicy>;
1211 using SegmentIntersectionType =
typename SegmentIntersectionAlgorithm::Intersection;
1212 SegmentIntersectionType segmentIs;
1214 Triangle triangle(Dune::GeometryTypes::simplex(2), std::array<Point, 3>({a, b, c}));
1215 Segment segment(Dune::GeometryTypes::simplex(1), std::array<Point, 2>({p, q}));
1216 if (SegmentIntersectionAlgorithm::intersection(triangle, segment, segmentIs))
1218 hasSegmentIs =
true;
1224 for (
const auto& ip : {p, q})
1240 const auto ap = p - a;
1241 const auto t = (ap*
normal)/denom;
1242 if (t < 0.0 - eps_)
return false;
1243 if (t > 1.0 + eps_)
return false;
1248 const auto v = (ac*e)/denom;
1249 if (v < -eps_ || v > 1.0 + eps_)
return false;
1250 const auto w = -(ab*e)/denom;
1251 if (w < -eps_ || v + w > 1.0 + eps_)
return false;
1255 const auto u = 1.0 - v - w;
1270template <
class Geometry1,
class Geometry2,
class Policy>
1283 template<
class P = Policy>
1294template <
class Geometry1,
class Geometry2,
class Policy>
1297 enum { dimworld = 3 };
1307 static constexpr ctype eps_ = 1.5e-7;
1317 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 0,
int> = 0>
1320 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
1321 DUNE_THROW(Dune::NotImplemented,
"segment-segment intersection detection for point-like intersections");
1331 template<
class P = Policy, std::enable_if_t<P::dimIntersection == 1,
int> = 0>
1334 static_assert(int(dimworld) == int(Geometry2::coorddimension),
"Can only collide geometries of same coordinate dimension");
1336 const auto& a = geo1.corner(0);
1337 const auto& b = geo1.corner(1);
1338 const auto ab = b-a;
1340 const auto& p = geo2.corner(0);
1341 const auto& q = geo2.corner(1);
1342 const auto pq = q-p;
1344 const auto abNorm2 = ab.two_norm2();
1345 const auto pqNorm2 = pq.two_norm2();
1348 const auto eps2 = eps_*max(abNorm2, pqNorm2);
1355 const auto ap = (p-a);
1356 const auto aq = (q-a);
1374 tp = clamp(tp, 0.0, abNorm2);
1375 tq = clamp(tq, 0.0, abNorm2);
1377 if (abs(tp-tq) < eps2)
Define some often used mathematical functions.
bool intersectsPointGeometry(const Dune::FieldVector< ctype, dimworld > &point, const Geometry &g)
Find out whether a point is inside a three-dimensional geometry.
Definition: geometry/intersectspointgeometry.hh:38
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
bool intersectsPointSimplex(const Dune::FieldVector< ctype, dimworld > &point, const Dune::FieldVector< ctype, dimworld > &p0, const Dune::FieldVector< ctype, dimworld > &p1, const Dune::FieldVector< ctype, dimworld > &p2, const Dune::FieldVector< ctype, dimworld > &p3)
Find out whether a point is inside a tetrahedron (p0, p1, p2, p3) (dimworld is 3)
Definition: geometry/intersectspointsimplex.hh:36
bool computeSegmentIntersection(const Geo1 &geo1, const Geo2 &geo2, ctype baseEps, ctype &tfirst, ctype &tlast, const GetFacetCornerIndices &getFacetCornerIndices, const ComputeNormalFunction &computeNormal)
Algorithm to find segment-like intersections of a polgon/polyhedron with a segment....
Definition: geometry/geometryintersection.hh:134
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
bool intersectsPointBoundingBox(const Dune::FieldVector< ctype, dimworld > &point, const ctype *b)
Check whether a point is intersectin a bounding box (dimworld == 3)
Definition: geometry/boundingboxtree.hh:304
typename DefaultPolicyChooser< Geometry1, Geometry2 >::type DefaultPolicy
Helper alias to define the default intersection policy.
Definition: geometry/geometryintersection.hh:113
constexpr Line line
Definition: couplingmanager1d3d_line.hh:52
Policy structure for point-like intersections.
Definition: geometry/geometryintersection.hh:43
static constexpr int dimIntersection
Definition: geometry/geometryintersection.hh:48
Point Intersection
Definition: geometry/geometryintersection.hh:49
ct ctype
Definition: geometry/geometryintersection.hh:44
Dune::FieldVector< ctype, dw > Point
Definition: geometry/geometryintersection.hh:45
static constexpr int dimWorld
Definition: geometry/geometryintersection.hh:47
Policy structure for segment-like intersections.
Definition: geometry/geometryintersection.hh:55
Segment Intersection
Definition: geometry/geometryintersection.hh:62
static constexpr int dimIntersection
Definition: geometry/geometryintersection.hh:61
Dune::FieldVector< ctype, dw > Point
Definition: geometry/geometryintersection.hh:57
static constexpr int dimWorld
Definition: geometry/geometryintersection.hh:60
std::array< Point, 2 > Segment
Definition: geometry/geometryintersection.hh:58
ct ctype
Definition: geometry/geometryintersection.hh:56
Policy structure for polygon-like intersections.
Definition: geometry/geometryintersection.hh:68
static constexpr int dimWorld
Definition: geometry/geometryintersection.hh:73
static constexpr int dimIntersection
Definition: geometry/geometryintersection.hh:74
ct ctype
Definition: geometry/geometryintersection.hh:69
Polygon Intersection
Definition: geometry/geometryintersection.hh:75
Dune::FieldVector< ctype, dw > Point
Definition: geometry/geometryintersection.hh:70
std::vector< Point > Polygon
Definition: geometry/geometryintersection.hh:71
Policy structure for polyhedron-like intersections.
Definition: geometry/geometryintersection.hh:81
std::vector< Point > Polyhedron
Definition: geometry/geometryintersection.hh:84
Dune::FieldVector< ctype, dw > Point
Definition: geometry/geometryintersection.hh:83
Polyhedron Intersection
Definition: geometry/geometryintersection.hh:88
static constexpr int dimIntersection
Definition: geometry/geometryintersection.hh:87
static constexpr int dimWorld
Definition: geometry/geometryintersection.hh:86
ct ctype
Definition: geometry/geometryintersection.hh:82
default policy chooser class
Definition: geometry/geometryintersection.hh:94
std::tuple_element_t< isDim, DefaultPolicies > type
Definition: geometry/geometryintersection.hh:108
A class for geometry collision detection and intersection calculation The class can be specialized fo...
Definition: geometry/geometryintersection.hh:216
typename Policy::ctype ctype
Definition: geometry/geometryintersection.hh:220
typename Policy::Intersection Intersection
Definition: geometry/geometryintersection.hh:222
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, Intersection &intersection)
Determine if the two geometries intersect and compute the intersection geometry.
Definition: geometry/geometryintersection.hh:225
typename Policy::Point Point
Definition: geometry/geometryintersection.hh:221
typename Policy::Intersection Intersection
Definition: geometry/geometryintersection.hh:250
typename Policy::ctype ctype
Definition: geometry/geometryintersection.hh:248
typename Policy::Point Point
Definition: geometry/geometryintersection.hh:249
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, Intersection &intersection)
Colliding two segments.
Definition: geometry/geometryintersection.hh:259
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, Intersection &intersection)
Colliding segment and convex polygon.
Definition: geometry/geometryintersection.hh:418
typename Policy::ctype ctype
Definition: geometry/geometryintersection.hh:402
typename Policy::Intersection Intersection
Definition: geometry/geometryintersection.hh:404
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, typename P::Intersection &intersection)
Colliding segment and convex polygon.
Definition: geometry/geometryintersection.hh:442
typename Policy::Point Point
Definition: geometry/geometryintersection.hh:403
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, typename Base::Intersection &intersection)
Colliding segment and convex polygon.
Definition: geometry/geometryintersection.hh:529
typename Policy::Intersection Intersection
Definition: geometry/geometryintersection.hh:549
typename Policy::ctype ctype
Definition: geometry/geometryintersection.hh:547
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, Intersection &intersection)
Colliding two polygons.
Definition: geometry/geometryintersection.hh:568
typename Policy::Point Point
Definition: geometry/geometryintersection.hh:548
typename Policy::Intersection Intersection
Definition: geometry/geometryintersection.hh:693
typename Policy::Point Point
Definition: geometry/geometryintersection.hh:692
typename Policy::ctype ctype
Definition: geometry/geometryintersection.hh:691
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, Intersection &intersection)
Colliding segment and convex polyhedron.
Definition: geometry/geometryintersection.hh:711
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, typename Base::Intersection &intersection)
Colliding segment and convex polyhedron.
Definition: geometry/geometryintersection.hh:821
typename Policy::Intersection Intersection
Definition: geometry/geometryintersection.hh:841
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, Intersection &intersection)
Colliding polygon and convex polyhedron.
Definition: geometry/geometryintersection.hh:862
typename Policy::Point Point
Definition: geometry/geometryintersection.hh:840
typename Policy::ctype ctype
Definition: geometry/geometryintersection.hh:839
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, typename Base::Intersection &intersection)
Colliding polygon and convex polyhedron.
Definition: geometry/geometryintersection.hh:1011
typename Policy::Intersection Intersection
Definition: geometry/geometryintersection.hh:1031
typename Policy::Point Point
Definition: geometry/geometryintersection.hh:1030
typename Policy::ctype ctype
Definition: geometry/geometryintersection.hh:1029
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, Intersection &intersection)
Colliding segment and convex polyhedron.
Definition: geometry/geometryintersection.hh:1047
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, Intersection &is)
Colliding segment and convex polyhedron.
Definition: geometry/geometryintersection.hh:1073
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, typename Base::Intersection &intersection)
Colliding segment and convex polygon.
Definition: geometry/geometryintersection.hh:1284
typename Policy::Intersection Intersection
Definition: geometry/geometryintersection.hh:1304
typename Policy::Point Point
Definition: geometry/geometryintersection.hh:1303
static bool intersection(const Geometry1 &geo1, const Geometry2 &geo2, Intersection &intersection)
Colliding two segments.
Definition: geometry/geometryintersection.hh:1318
typename Policy::ctype ctype
Definition: geometry/geometryintersection.hh:1302
An axis-aligned bounding box volume hierarchy for dune grids.
A function to compute the convex hull of a point cloud and a function to triangulate the polygon area...
Detect if a point intersects a geometry.