MDStressLab++
Trigonometric.cpp
Go to the documentation of this file.
1 /*
2  * Trigonometric.cpp
3  *
4  * Created on: Jan 9, 2020
5  * Author: Nikhil
6  */
7 
8 #include "Trigonometric.h"
9 #include "typedef.h"
10 #include <math.h>
11 
13 
15 
16 double Trigonometric::operator()(const double& t) const
17 {
18  // Trigonometric weighting function
19  if (t <= -1 || t >= 1)
20  {
21  return 0.0;
22  }
23  else
24  {
25  return 0.5 * (1.0 + cos(t * M_PI));
26  }
27 }
28 
29 double Trigonometric::integrate(const Vector3d& vec1_pull_seg, const Vector3d& vec2_pull_seg) const
30 {
31  Vector3d a, b;
32  double result = 1.0;
33  a = (vec1_pull_seg - vec2_pull_seg) * M_PI;
34  b = vec2_pull_seg * M_PI;
35 
36  // 0
37  // 1
38  // 2
39  for (int i = 0; i <= 2; i++)
40  {
41  if (fabs(a(i)) < epsilon)
42  {
43  result = result + cos(b(i));
44  }
45  else
46  {
47  result = result + (sin(a(i) + b(i)) - sin(b(i))) / a(i);
48  }
49  }
50 
51  // 01
52  if (fabs(a(0) - a(1)) < epsilon)
53  {
54  result = result + cos(b(0) - b(1)) / 2.0;
55  }
56  else
57  {
58  result = result + (sin(b(0) - b(1) + a(0) - a(1)) - sin(b(0) - b(1))) / ((a(0) - a(1)) * 2.0);
59  }
60 
61  if (fabs(a(0) + a(1)) < epsilon)
62  {
63  result = result + cos(b(0) + b(1)) / 2.0;
64  }
65  else
66  {
67  result = result + (sin(b(0) + b(1) + a(0) + a(1)) - sin(b(0) + b(1))) / ((a(0) + a(1)) * 2.0);
68  }
69 
70  // 02
71  if (fabs(a(0) - a(2)) < epsilon)
72  {
73  result = result + cos(b(0) - b(2)) / 2.0;
74  }
75  else
76  {
77  result = result + (sin(b(0) - b(2) + a(0) - a(2)) - sin(b(0) - b(2))) / ((a(0) - a(2)) * 2.0);
78  }
79 
80  if (fabs(a(0) + a(2)) < epsilon)
81  {
82  result = result + cos(b(0) + b(2)) / 2.0;
83  }
84  else
85  {
86  result = result + (sin(b(0) + b(2) + a(0) + a(2)) - sin(b(0) + b(2))) / ((a(0) + a(2)) * 2.0);
87  }
88 
89  // 12
90  if (fabs(a(1) - a(2)) < epsilon)
91  {
92  result = result + cos(b(1) - b(2)) / 2.0;
93  }
94  else
95  {
96  result = result + (sin(b(1) - b(2) + a(1) - a(2)) - sin(b(1) - b(2))) / ((a(1) - a(2)) * 2.0);
97  }
98 
99  if (fabs(a(1) + a(2)) < epsilon)
100  {
101  result = result + cos(b(1) + b(2)) / 2.0;
102  }
103  else
104  {
105  result = result + (sin(b(1) + b(2) + a(1) + a(2)) - sin(b(1) + b(2))) / ((a(1) + a(2)) * 2.0);
106  }
107 
108  // 012
109  if (fabs(a(0) - a(1) - a(2)) < epsilon)
110  {
111  result = result + cos(b(0) - b(1) - b(2)) / 4.0;
112  }
113  else
114  {
115  result = result + (sin(b(0) - b(1) - b(2) + a(0) - a(1) - a(2)) - sin(b(0) - b(1) - b(2))) / ((a(0) - a(1) - a(2)) * 4.0);
116  }
117 
118  if (fabs(a(0) + a(1) - a(2)) < epsilon)
119  {
120  result = result + cos(b(0) + b(1) - b(2)) / 4.0;
121  }
122  else
123  {
124  result = result + (sin(b(0) + b(1) - b(2) + a(0) + a(1) - a(2)) - sin(b(0) + b(1) - b(2))) / ((a(0) + a(1) - a(2)) * 4.0);
125  }
126 
127  if (fabs(a(0) - a(1) + a(2)) < epsilon)
128  {
129  result = result + cos(b(0) - b(1) + b(2)) / 4.0;
130  }
131  else
132  {
133  result = result + (sin(b(0) - b(1) + b(2) + a(0) - a(1) + a(2)) - sin(b(0) - b(1) + b(2))) / ((a(0) - a(1) + a(2)) * 4.0);
134  }
135 
136  if (fabs(a(0) + a(1) + a(2)) < epsilon)
137  {
138  result = result + cos(b(0) + b(1) + b(2)) / 4.0;
139  }
140  else
141  {
142  result = result + (sin(b(0) + b(1) + b(2) + a(0) + a(1) + a(2)) - sin(b(0) + b(1) + b(2))) / ((a(0) + a(1) + a(2)) * 4.0);
143  }
144 
145  return result;
146 }
147 
148 
149 
150 
const double epsilon
Definition: typedef.h:73
virtual ~Trigonometric()
double integrate(const Vector3d &vec1_pull_seg, const Vector3d &vec2_pull_seg) const
Eigen::Matrix< double, 1, DIM, Eigen::RowMajor > Vector3d
Definition: typedef.h:60
double operator()(const double &t) const