Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
LineSegmentIntersection.cpp
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MoDELib is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef model_LineSegmentIntersection_CPP_
9#define model_LineSegmentIntersection_CPP_
10
11#include <cfloat>
12#include <tuple>
13#include <map>
14#include <stdexcept>
15#include <Eigen/Dense>
16
19
20namespace model
21{
22 /**********************************************************************/
23 template <int dim>
24 typename LineSegmentIntersection<dim>::SolutionType LineSegmentIntersection<dim>::findIntersections(const VectorDimD& A0,
25 const VectorDimD& D0,
26 const VectorDimD& P0,
27 const VectorDimD& P1)
28 {
50
51
52 LineLineIntersection<dim> lli(A0,D0,P0,P1-P0);
53
54 switch (lli.type)
55 {
57 {
58 return SolutionType(PARALLEL,A0,0.5*(P0+P1),0.0,0.5); // TODO COMPUTE CLOSEST POINTS
59 break;
60 }
61
63 {
64 return SolutionType(COINCIDENT,A0,0.5*(P0+P1),0.0,0.5); // TODO COMPUTE CLOSEST POINTS
65 break;
66 }
67
69 {
70 if(lli.u1>=0.0 && lli.u1<=1.0)
71 {
72 return SolutionType(INCIDENT,lli.x0,lli.x1,lli.u0,lli.u1);
73 }
74 else if(lli.u1<0.0)
75 {
76 return SolutionType(OUTSIDE,lli.x0,P0,lli.u0,0.0);
77 }
78 else //lli.u1>1.0
79 {
80 return SolutionType(OUTSIDE,lli.x0,P1,lli.u0,1.0);
81 }
82 break;
83 }
84
85 default: // SKEW
86 {
87 return SolutionType(SKEW,A0,0.5*(P0+P1),0.0,0.5); // TODO COMPUTE CLOSEST POINTS
88 break;
89 }
90 }
91
92 }
93
94 /**********************************************************************/
95 template<int dim>
97 const VectorDimD& D0,
98 const VectorDimD& P0,
99 const VectorDimD& P1) :
100 /* init */ sol(findIntersections(A0,D0,P0,P1))
101 /* init */,type(std::get<0>(sol))
102 /* init */,x0(std::get<1>(sol))
103 /* init */,x1(std::get<2>(sol))
104 /* init */,u0(std::get<3>(sol))
105 /* init */,u1(std::get<4>(sol))
106 {
107
108 }
109
110 template class LineSegmentIntersection<3>;
111 template class LineSegmentIntersection<2>;
112
113} /* namespace model */
114#endif
LineSegmentIntersection(const VectorDimD &A0, const VectorDimD &D0, const VectorDimD &P0, const VectorDimD &P1)
Eigen::Matrix< double, dim, 1 > VectorDimD
std::tuple< IntersectionType, VectorDimD, VectorDimD, double, double > SolutionType
@ OUTSIDE
Definition triangle.cpp:373