MDStressLab++
Loading...
Searching...
No Matches
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
16double 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
30{
31 return 1.0;
32}
33
34double Trigonometric::integrate(const Vector3d& vec1_pull_seg, const Vector3d& vec2_pull_seg) const
35{
36 Vector3d a, b;
37 double result = 1.0;
38 a = (vec1_pull_seg - vec2_pull_seg) * M_PI;
39 b = vec2_pull_seg * M_PI;
40
41 // 0
42 // 1
43 // 2
44 for (int i = 0; i <= 2; i++)
45 {
46 if (fabs(a(i)) < epsilon)
47 {
48 result = result + cos(b(i));
49 }
50 else
51 {
52 result = result + (sin(a(i) + b(i)) - sin(b(i))) / a(i);
53 }
54 }
55
56 // 01
57 if (fabs(a(0) - a(1)) < epsilon)
58 {
59 result = result + cos(b(0) - b(1)) / 2.0;
60 }
61 else
62 {
63 result = result + (sin(b(0) - b(1) + a(0) - a(1)) - sin(b(0) - b(1))) / ((a(0) - a(1)) * 2.0);
64 }
65
66 if (fabs(a(0) + a(1)) < epsilon)
67 {
68 result = result + cos(b(0) + b(1)) / 2.0;
69 }
70 else
71 {
72 result = result + (sin(b(0) + b(1) + a(0) + a(1)) - sin(b(0) + b(1))) / ((a(0) + a(1)) * 2.0);
73 }
74
75 // 02
76 if (fabs(a(0) - a(2)) < epsilon)
77 {
78 result = result + cos(b(0) - b(2)) / 2.0;
79 }
80 else
81 {
82 result = result + (sin(b(0) - b(2) + a(0) - a(2)) - sin(b(0) - b(2))) / ((a(0) - a(2)) * 2.0);
83 }
84
85 if (fabs(a(0) + a(2)) < epsilon)
86 {
87 result = result + cos(b(0) + b(2)) / 2.0;
88 }
89 else
90 {
91 result = result + (sin(b(0) + b(2) + a(0) + a(2)) - sin(b(0) + b(2))) / ((a(0) + a(2)) * 2.0);
92 }
93
94 // 12
95 if (fabs(a(1) - a(2)) < epsilon)
96 {
97 result = result + cos(b(1) - b(2)) / 2.0;
98 }
99 else
100 {
101 result = result + (sin(b(1) - b(2) + a(1) - a(2)) - sin(b(1) - b(2))) / ((a(1) - a(2)) * 2.0);
102 }
103
104 if (fabs(a(1) + a(2)) < epsilon)
105 {
106 result = result + cos(b(1) + b(2)) / 2.0;
107 }
108 else
109 {
110 result = result + (sin(b(1) + b(2) + a(1) + a(2)) - sin(b(1) + b(2))) / ((a(1) + a(2)) * 2.0);
111 }
112
113 // 012
114 if (fabs(a(0) - a(1) - a(2)) < epsilon)
115 {
116 result = result + cos(b(0) - b(1) - b(2)) / 4.0;
117 }
118 else
119 {
120 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);
121 }
122
123 if (fabs(a(0) + a(1) - a(2)) < epsilon)
124 {
125 result = result + cos(b(0) + b(1) - b(2)) / 4.0;
126 }
127 else
128 {
129 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);
130 }
131
132 if (fabs(a(0) - a(1) + a(2)) < epsilon)
133 {
134 result = result + cos(b(0) - b(1) + b(2)) / 4.0;
135 }
136 else
137 {
138 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);
139 }
140
141 if (fabs(a(0) + a(1) + a(2)) < epsilon)
142 {
143 result = result + cos(b(0) + b(1) + b(2)) / 4.0;
144 }
145 else
146 {
147 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);
148 }
149
150 return result;
151}
152
153
154
double operator()(const double &t) const
Evaluate on .
virtual ~Trigonometric()
double integral() const
Return for this shape.
double integrate(const Vector3d &vec1_pull_seg, const Vector3d &vec2_pull_seg) const
Evaluate the expanded segment integral used by the LDAD bond function.
Eigen::Matrix< double, 1, DIM, Eigen::RowMajor > Vector3d
Definition typedef.h:60
const double epsilon
Definition typedef.h:73