12 #ifdef LWC_PARAM_ANGLE
28 #ifndef LARWC_DTNF_NEW
36 double z =
P.z() -
lwc()->m_StraightStartSection;
39 #ifdef LWC_PARAM_ANGLE //old variant
40 const double alpha =
lwc()->parameterized_slant_angle(
P.y());
44 const double cos_a = scalpha.
cs, sin_a = scalpha.
sn;
45 #else // parameterized sine
47 lwc()->m_vsincos_par.eval(
P.y(), sin_a, cos_a);
50 int nqwave = (
z < 0.) ? 0 :
int(
z /
lwc()->m_QuarterWaveLength);
54 bool begin_qw =
false;
55 if((nqwave % 2) != 0){
66 if(nqwave != 0 && nqwave !=
lwc()->m_NumberOfHalfWaves){
67 z -= nqwave *
lwc()->m_HalfWaveLength;
69 if((nqwave % 2) == 0)
x = -
x;
76 const double z_prime =
z * cos_a +
x * sin_a;
77 const double x_prime =
x * cos_a -
z * sin_a;
78 const double straight_part = (
lwc()->m_QuarterWaveLength -
lwc()->m_FanFoldRadius * sin_a) / cos_a;
79 if(z_prime > straight_part){
80 const double dz = straight_part - z_prime;
81 const double dx = x_prime +
lwc()->m_FanFoldRadius;
83 }
else if(z_prime > -straight_part){
86 const double dz = straight_part + z_prime;
87 const double dx = x_prime -
lwc()->m_FanFoldRadius;
98 z =
lwc()->m_ActiveLength -
z;
101 const double tan_beta = sin_a/(1.0 + cos_a);
102 const double local_straight_section =
lwc()->m_FanFoldRadius * tan_beta;
103 if(
z < - local_straight_section &&
104 (
x <
lwc()->m_FanFoldRadius ||
105 x < -
lwc()->m_StraightStartSection *
z / local_straight_section / tan_beta ) )
110 const double z_prime =
z * cos_a +
x * sin_a;
111 const double x_prime =
x * cos_a -
z * sin_a;
112 if (z_prime < local_straight_section) {
113 const double dz = local_straight_section - z_prime;
114 const double dx = x_prime -
lwc()->m_FanFoldRadius;
117 const double straight_part = (
lwc()->m_QuarterWaveLength -
lwc()->m_FanFoldRadius * sin_a) / cos_a;
118 if (z_prime <= straight_part) {
121 const double dz = straight_part - z_prime;
122 const double dx = x_prime +
lwc()->m_FanFoldRadius;
131 double dd = DistanceToTheNeutralFibre_ref(
P);
134 std::cout <<
"DTNF MISMATCH " <<
this <<
" " <<
P <<
" "
144 #ifdef LARWC_DTNF_NEW
150 double z =
P.z() -
lwc()->m_StraightStartSection;
153 #ifdef LWC_PARAM_ANGLE //old variant
154 const double alpha =
lwc()->parameterized_slant_angle(
P.y());
156 double cos_a = scalpha.
cs, sin_a = scalpha.
sn;
157 #else // parameterized sine
159 lwc()->m_vsincos_par.eval(
P.y(), sin_a, cos_a);
163 if(
z >
lwc()->m_QuarterWaveLength){
164 if(
z < m_EndQuarterWave){
165 unsigned int nhwave = (
unsigned int)(
z /
lwc()->m_HalfWaveLength + 0.5);
166 z -=
lwc()->m_HalfWaveLength * nhwave;
167 const double straight_part = (
lwc()->m_QuarterWaveLength -
lwc()->m_FanFoldRadius * sin_a) / cos_a;
169 if(nhwave == 0) sin_a = - sin_a;
170 double z_prime =
z * cos_a +
x * sin_a;
171 const double x_prime =
z * sin_a -
x * cos_a;
172 if(z_prime > straight_part){
173 const double dz = z_prime - straight_part;
175 const double dx = x_prime +
lwc()->m_FanFoldRadius;
176 return sqrt(dz*dz +
dx*
dx) -
lwc()->m_FanFoldRadius;
178 const double dx = x_prime -
lwc()->m_FanFoldRadius;
179 return lwc()->m_FanFoldRadius - sqrt(dz*dz +
dx*
dx);
182 z_prime += straight_part;
186 const double &dz = z_prime;
188 const double dx = x_prime -
lwc()->m_FanFoldRadius;
189 return lwc()->m_FanFoldRadius - sqrt(dz*dz +
dx*
dx);
191 const double dx = x_prime +
lwc()->m_FanFoldRadius;
192 return sqrt(dz*dz +
dx*
dx) -
lwc()->m_FanFoldRadius;
196 z =
lwc()->m_ActiveLength -
z;
204 const double tan_beta = sin_a/(1.0 + cos_a);
205 const double local_straight_section =
lwc()->m_FanFoldRadius * tan_beta;
206 if(
z < - local_straight_section &&
207 (
x <
lwc()->m_FanFoldRadius ||
208 x < -
lwc()->m_StraightStartSection *
z / local_straight_section / tan_beta ))
213 const double z_prime =
z * cos_a +
x * sin_a;
214 const double x_prime =
x * cos_a -
z * sin_a;
215 if (z_prime < local_straight_section) {
216 const double dz = local_straight_section - z_prime;
217 const double dx = x_prime -
lwc()->m_FanFoldRadius;
218 if(sqw)
return lwc()->m_FanFoldRadius - sqrt(dz*dz +
dx*
dx);
219 else return sqrt(dz*dz +
dx*
dx) -
lwc()->m_FanFoldRadius;
221 const double straight_part =
222 (
lwc()->m_QuarterWaveLength -
lwc()->m_FanFoldRadius * sin_a) / cos_a;
223 if (z_prime <= straight_part) {
224 return sqw? x_prime: (-x_prime);
226 const double dz = straight_part - z_prime;
227 const double dx = x_prime +
lwc()->m_FanFoldRadius;
228 if(sqw)
return sqrt(dz*dz +
dx*
dx) -
lwc()->m_FanFoldRadius;
229 else return lwc()->m_FanFoldRadius - sqrt(dz*dz +
dx*
dx);
244 #ifdef LWC_PARAM_ANGLE //old variant
247 const double cos_a = scalpha.
cs, sin_a = scalpha.
sn;
248 #else // parameterized sine
250 lwc()->m_vsincos_par.eval(
P.y(), sin_a, cos_a);
254 if(
z < 0.) nqwave = 0;
255 else nqwave =
int(
z /
lwc()->m_QuarterWaveLength);
256 bool begin_qw =
false;
257 if((nqwave % 2) != 0){
262 if(nqwave != 0 && nqwave !=
lwc()->m_NumberOfHalfWaves){
264 if((nqwave % 2) == 0)
x = -
x;
269 const double z_prime =
z * cos_a +
x * sin_a;
270 const double x_prime =
x * cos_a -
z * sin_a;
272 const double dz = straight_part - z_prime;
273 if (dz > 0)
result.set(0.,
y, z_prime);
275 double a =
atan(fabs(dz / (x_prime +
lwc()->m_FanFoldRadius)));
276 result.set(
lwc()->m_FanFoldRadius * (
cos(
a) - 1),
y, straight_part +
lwc()->m_FanFoldRadius *
sin(
a));
278 result.rotateY(asin(sin_a));
286 if(nqwave == 0)
x = -
x;
288 const double tan_beta = sin_a/(1.0+cos_a);
290 if(
z < - local_straight_section &&
291 (
x <
lwc()->m_FanFoldRadius ||
292 x < -
lwc()->m_StraightStartSection *
z / local_straight_section / tan_beta))
297 const double z_prime =
z * cos_a +
x * sin_a;
298 const double x_prime =
x * cos_a -
z * sin_a;
299 if(z_prime < local_straight_section) {
300 double a = fabs(
atan((local_straight_section - z_prime) / (x_prime -
lwc()->m_FanFoldRadius)));
302 result.set(
lwc()->m_FanFoldRadius * (1 -
cos(
a)),
y, local_straight_section -
lwc()->m_FanFoldRadius *
sin(
a));
305 if(z_prime <= straight_part) {
308 double a = fabs(
atan((straight_part - z_prime) / (x_prime +
lwc()->m_FanFoldRadius)) );
309 result.set(
lwc()->m_FanFoldRadius * (
cos(
a) - 1),
y, straight_part +
lwc()->m_FanFoldRadius *
sin(
a));
312 result.rotateY(asin(sin_a));
332 #ifdef LWC_PARAM_ANGLE //old variant
335 double cos_a = scalpha.
cs, sin_a = scalpha.
sn;
336 #else // parameterized sine
338 lwc()->m_vsincos_par.eval(
P.y(), sin_a, cos_a);
342 if(
z >
lwc()->m_QuarterWaveLength){
347 const double straight_part =
350 if(nhwave == 0) sin_a = - sin_a;
351 const double z_prime =
z * cos_a +
x * sin_a;
352 if(z_prime > straight_part){
353 const double x_prime =
x * cos_a -
z * sin_a;
354 const double dz = straight_part - z_prime;
355 double a1 =
atan(fabs(dz / (x_prime +
lwc()->m_FanFoldRadius)));
358 result.set(
x1*cos_a - z1*sin_a,
y, z1*cos_a + z1*sin_a);
360 }
else if(z_prime > -straight_part){
361 result.set(-z_prime * sin_a,
y, z_prime*cos_a + zshift);
364 const double x_prime =
x * cos_a -
z * sin_a;
365 const double dz = straight_part + z_prime;
366 double a1 =
atan(fabs(dz / (x_prime +
lwc()->m_FanFoldRadius)));
369 result.set(
x1*cos_a - z1*sin_a,
y, z1*cos_a + z1*sin_a);
381 const double tan_beta = sin_a / (1.0 + cos_a);
383 if(
z < - local_straight_section &&
384 (
x <
lwc()->m_FanFoldRadius ||
385 x < -
lwc()->m_StraightStartSection *
z / local_straight_section / tan_beta))
390 const double z_prime =
z * cos_a +
x * sin_a;
391 const double x_prime =
x * cos_a -
z * sin_a;
392 if(z_prime < local_straight_section) {
393 double a = fabs(
atan((local_straight_section - z_prime) / (x_prime -
lwc()->m_FanFoldRadius)));
394 result.set(
lwc()->m_FanFoldRadius * (1 -
cos(
a)),
y, local_straight_section -
lwc()->m_FanFoldRadius *
sin(
a));
397 if(z_prime <= straight_part) {
400 double a = fabs(
atan((straight_part - z_prime) / (x_prime +
lwc()->m_FanFoldRadius)) );
401 result.set(
lwc()->m_FanFoldRadius * (
cos(
a) - 1),
y, straight_part +
lwc()->m_FanFoldRadius *
sin(
a));
404 result.rotateY(asin(sin_a));
424 #ifdef LWC_PARAM_ANGLE //old variant
429 const double cos_a = scalpha.
cs, sin_a = scalpha.
sn;
433 lwc()->m_vsincos_par.eval(
P.y(), sin_a, cos_a);
438 if(
z < 0.) nqwave = 0;
439 else nqwave =
int(
z /
lwc()->m_QuarterWaveLength);
440 bool begin_qw =
false;
441 if((nqwave % 2) != 0){
450 if(nqwave != 0 && nqwave !=
lwc()->m_NumberOfHalfWaves){
456 if((nqwave % 2) == 0){
457 if(begin_qw) local_side = -1;
459 if(!begin_qw) local_side = -1;
464 if(dz >=
rho * sin_a){
468 + sqrt(
rho *
rho - dz * dz);
483 const double tan_beta = sin_a/(1.0+cos_a);
484 const double min_local_fold_region = rho1i * tan_beta;
486 if(
z <= - min_local_fold_region){
491 const double max_local_fold_region = rho1 * sin_a - min_local_fold_region;
493 if(
z < max_local_fold_region){
494 z += min_local_fold_region;
495 result = rho1 - sqrt(rho1 * rho1 -
z *
z);
502 if(dz >=
rho * sin_a){
506 + sqrt(
rho *
rho - dz * dz);