/Users/enrico/Ricerca/develop/PINS/pins-mechatronix/LibSources/submodules/Splines/src/SplinesUtils.hh Source FileΒΆ

Splines: /Users/enrico/Ricerca/develop/PINS/pins-mechatronix/LibSources/submodules/Splines/src/SplinesUtils.hh Source File
Splines
SplinesUtils.hh
1/*--------------------------------------------------------------------------*\
2 | |
3 | Copyright (C) 2016 |
4 | |
5 | , __ , __ |
6 | /|/ \ /|/ \ |
7 | | __/ _ ,_ | __/ _ ,_ |
8 | | \|/ / | | | | \|/ / | | | |
9 | |(__/|__/ |_/ \_/|/|(__/|__/ |_/ \_/|/ |
10 | /| /| |
11 | \| \| |
12 | |
13 | Enrico Bertolazzi |
14 | Dipartimento di Ingegneria Industriale |
15 | Universita` degli Studi di Trento |
16 | email: enrico.bertolazzi@unitn.it |
17 | |
18\*--------------------------------------------------------------------------*/
19
20#pragma once
21
22#ifndef SPLINES_UTILS_HH
23#define SPLINES_UTILS_HH
24
25#include "Splines.hh"
26
27namespace Splines {
28
29 using std::fpclassify;
30
31 /*
32 // __ _ _ _ _ _ __ __
33 // / _(_)_ __ (_) |_ ___ __| (_)/ _|/ _| ___ _ __ ___ _ __ ___ ___
34 // | |_| | '_ \| | __/ _ \ / _` | | |_| |_ / _ \ '__/ _ \ '_ \ / __/ _ \
35 // | _| | | | | | || __/ | (_| | | _| _| __/ | | __/ | | | (_| __/
36 // |_| |_|_| |_|_|\__\___| \__,_|_|_| |_| \___|_| \___|_| |_|\___\___|
37 */
38
39 #ifndef DOXYGEN_SHOULD_SKIP_THIS
40
41 /*\
42 | Given
43 | DL = (y[k]-y[k-1])/hL; hL = x[k]-x[k-1];
44 | DR = (y[k+1]-y[k])/hR; hR = x[k+1]-x[k];
45 | approximate the first derivative at x[k]
46 \*/
47 static
48 inline
50 first_deriv3p_C(
51 real_type DL, real_type hL,
52 real_type DR, real_type hR
53 ) {
54 return (DL*hR+DR*hL)/(hR+hL);
55 }
56
57 /*\
58 | Given
59 | DL = (y[k]-y[k-1])/hL; hL = x[k]-x[k-1];
60 | DR = (y[k+1]-y[k])/hR; hR = x[k+1]-x[k];
61 | approximate the first derivative at x[k-1]
62 \*/
63 static
64 inline
66 first_deriv3p_L(
67 real_type DL, real_type hL,
68 real_type DR, real_type hR
69 ) {
70 return ((2*DL-DR)*hL+DL*hR)/(hR+hL);
71 }
72
73 /*\
74 | Given
75 | DL = (y[k]-y[k-1])/hL; hL = x[k]-x[k-1];
76 | DR = (y[k+1]-y[k])/hR; hR = x[k+1]-x[k];
77 | approximate the first derivative at x[k+1]
78 \*/
79 static
80 inline
82 first_deriv3p_R(
83 real_type DL, real_type hL,
84 real_type DR, real_type hR
85 ) {
86 return ((2*DR-DL)*hR+DR*hL)/(hR+hL);
87 }
88
89 /*\
90 | Given
91 | DLLL = (y[k-2]-y[k-3])/hLLL; hLLL = x[k-2]-x[k-3];
92 | DLL = (y[k-1]-y[k-2])/hLL; hLL = x[k-1]-x[k-2];
93 | DL = (y[k]-y[k-1])/hL; hL = x[k]-x[k-1];
94 | approximate the first derivative at x[k]
95 \*/
97 first_deriv4p_R(
98 real_type DLLL, real_type hLLL,
99 real_type DLL, real_type hLL,
100 real_type DL, real_type hL
101 );
102
103 /*\
104 | Given
105 | DR = (y[k+1]-y[k])/hR; hR = x[k+1]-x[k];
106 | DRR = (y[k+2]-y[k+1])/hRR; hRR = x[k+2]-x[k+1];
107 | DRRR = (y[k+3]-y[k+2])/hRRR; hRRR = x[k+3]-x[k+2];
108 | approximate the first derivative at x[k]
109 \*/
111 first_deriv4p_L(
112 real_type DR, real_type hR,
113 real_type DRR, real_type hRR,
114 real_type DRRR, real_type hRRR
115 );
116
117 /*\
118 | Given
119 | DLL = (y[k-1]-y[k-2])/hLL; hLL = x[k-1]-x[k-2];
120 | DL = (y[k]-y[k-1])/hL; hL = x[k]-x[k-1];
121 | DR = (y[k+1]-y[k])/hR; hR = x[k+1]-x[k];
122 | DRR = (y[k+2]-y[k-1])/hRR; hRR = x[k+2]-x[k+1];
123 | approximate the first derivative at x[k]
124 \*/
126 first_deriv5p_C(
127 real_type DLL, real_type hLL,
128 real_type DL, real_type hL,
129 real_type DR, real_type hR,
130 real_type DRR, real_type hRR
131 );
132
133 /*\
134 | Given
135 | DLL = (y[k-1]-y[k-2])/hLL; hLL = x[k-1]-x[k-2];
136 | DL = (y[k]-y[k-1])/hL; hL = x[k]-x[k-1];
137 | DR = (y[k+1]-y[k])/hR; hR = x[k+1]-x[k];
138 | DRR = (y[k+2]-y[k-1])/hRR; hRR = x[k+2]-x[k+1];
139 | approximate the first derivative at x[k-1]
140 \*/
142 first_deriv5p_L(
143 real_type DLL, real_type hLL,
144 real_type DL, real_type hL,
145 real_type DR, real_type hR,
146 real_type DRR, real_type hRR
147 );
148
149 /*\
150 | Given
151 | DLL = (y[k-1]-y[k-2])/hLL; hLL = x[k-1]-x[k-2];
152 | DL = (y[k]-y[k-1])/hL; hL = x[k]-x[k-1];
153 | DR = (y[k+1]-y[k])/hR; hR = x[k+1]-x[k];
154 | DRR = (y[k+2]-y[k-1])/hRR; hRR = x[k+2]-x[k+1];
155 | approximate the first derivative at x[k+1]
156 \*/
158 first_deriv5p_R(
159 real_type DLL, real_type hLL,
160 real_type DL, real_type hL,
161 real_type DR, real_type hR,
162 real_type DRR, real_type hRR
163 );
164
166 second_deriv3p_C(
167 real_type SL,
168 real_type hL,
169 real_type SR,
170 real_type hR,
171 real_type dpL,
172 real_type dp0,
173 real_type dpR
174 );
175
177 second_deriv3p_C(
178 real_type SL,
179 real_type hL,
180 real_type SR,
181 real_type hR,
182 real_type dp0
183 );
184
186 second_deriv3p_L(
187 real_type SL,
188 real_type hL,
189 real_type SR,
190 real_type hR,
191 real_type dpL,
192 real_type dp0,
193 real_type dpR
194 );
195
197 second_deriv3p_L(
198 real_type SL,
199 real_type hL,
200 real_type SR,
201 real_type hR,
202 real_type dpL
203 );
204
206 second_deriv3p_R(
207 real_type SL,
208 real_type hL,
209 real_type SR,
210 real_type hR,
211 real_type dpL,
212 real_type dp0,
213 real_type dpR
214 );
215
217 second_deriv3p_R(
218 real_type SL,
219 real_type hL,
220 real_type SR,
221 real_type hR,
222 real_type dpR
223 );
224
225 void
226 first_derivative_build(
227 real_type const X[],
228 real_type const Y[],
229 real_type Yp[],
230 integer npts
231 );
232
233 void
234 second_derivative_build(
235 real_type const X[],
236 real_type const Y[],
237 real_type const Yp[],
238 real_type Ypp[],
239 integer npts
240 );
241
242 #endif
243
244}
245
246#endif
Definition SplineAkima.cc:50
int integer
Signed integer type for splines.
Definition Splines.hh:58
double real_type
Floating point type for splines.
Definition Splines.hh:57