Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
CatmullRom.h
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_CatmullRom_H_
9#define model_CatmullRom_H_
10
11#include <set>
12#include <Eigen/Dense>
13#include <SplineSegment.h>
14#include <LoopLink.h>
15
16namespace model
17{
18
20 {
21
22 /**********************************************************************/
23 template <typename T>
24 static Eigen::Matrix<double,T::dim,1> loopTangent(const std::set<LoopLink<T>*>& segmentSet)
25 {
26
27 double cT=0.0;
28 for(const auto& link : segmentSet)
29 {
30 const double cL=link->pLink->parametricChordLength();
31 cT+=cL;
32 }
33
34 Eigen::Matrix<double,T::dim,1> temp=Eigen::Matrix<double,T::dim,1>::Zero();
35 if(cT>0.0)
36 {
37 for(const auto& link : segmentSet)
38 {
39 const double cL=link->pLink->parametricChordLength();
40 if(cL>0.0)
41 {
42 temp+=(link->sink()->get_P()-link->source()->get_P())/cL*(cT-cL)/cT;
43 }
44 }
45 }
46
47
48 return temp;
49 }
50
51 /**********************************************************************/
52 template <typename T>
53 static std::map<size_t,std::pair<double,Eigen::Matrix<double,T::dim,1>>> loopTangentCoeffs(const std::set<LoopLink<T>*>& segmentSet)
54 {
59
60 double cT=0.0;
61 for(const auto& link : segmentSet)
62 {
63 const double cL=link->pLink->parametricChordLength();
64 cT+=cL;
65 }
66
67 //Eigen::Matrix<double,T::dim,1> temp=Eigen::Matrix<double,T::dim,1>::Zero();
68 std::map<size_t,std::pair<double,Eigen::Matrix<double,T::dim,1>>> temp;
69
70 for(const auto& link : segmentSet)
71 {
72 temp[link->source()->snID()]=std::make_pair(0.0,link->source()->get_P());
73 temp[link-> sink()->snID()]=std::make_pair(0.0,link-> sink()->get_P());
74 }
75
76 if(cT>0.0)
77 {
78 for(const auto& link : segmentSet)
79 {
80 const double cL=link->pLink->parametricChordLength();
81 if(cL>0.0)
82 {
83 temp[link->source()->snID()].first-=1.0/cL*(cT-cL)/cT;
84 temp[link-> sink()->snID()].first+=1.0/cL*(cT-cL)/cT;
85 }
86 }
87 }
88
89
90 return temp;
91 }
92
93 };
94
95}
96#endif
static Eigen::Matrix< double, T::dim, 1 > loopTangent(const std::set< LoopLink< T > * > &segmentSet)
Definition CatmullRom.h:24
static std::map< size_t, std::pair< double, Eigen::Matrix< double, T::dim, 1 > > > loopTangentCoeffs(const std::set< LoopLink< T > * > &segmentSet)
Definition CatmullRom.h:53
vertex temp