1
2
3
4
5
6
7
8
9
10
11
|
#ifndef FADE_HH
#define FADE_HH
#include <math.h> // tanh
#include "constants.hh" // pi
inline double
fade(const double x,
const double x1,
const double x2,
|
|
|
1
2
3
4
5
6
7
8
9
10
11
|
#ifndef FADE_HH
#define FADE_HH
#include <cmath> // tanh
#include "constants.hh" // pi
inline double
fade(const double x,
const double x1,
const double x2,
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
const double x1,
const double x2,
const double y1,
const double y2)
{
double X1 = x1, X2 = x2;
if (x1 > x2) {
cerr << "* Warning: chkfade; x2 > x1, swapping" << endl;
X1 = x2;
X2 = x1;
}
return ((x <= X1) ? y1 : (x > X2) ? y2 : fade(x, X1, X2, y1, y2));
}
#endif // FADE_HH
|
|
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
const double x1,
const double x2,
const double y1,
const double y2)
{
double X1 = x1, X2 = x2;
if (x1 > x2) {
std::cerr << "* Warning: chkfade; x2 > x1, swapping" << std::endl;
X1 = x2;
X2 = x1;
}
return ((x <= X1) ? y1 : (x > X2) ? y2 : fade(x, X1, X2, y1, y2));
}
#endif // FADE_HH
|