diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-12-19 13:00:37 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-12-26 10:08:55 +0100 |
| commit | df574ae332d57f556fd56314883b3354cab1d0ff (patch) | |
| tree | 63a68d40d7ed7932d6329d9c7baa340bb6294f7f /src/deriv.cpp | |
| parent | e6de172371ea203f6393d745641d66c82b5b13e2 (diff) | |
| download | PROJ-df574ae332d57f556fd56314883b3354cab1d0ff.tar.gz PROJ-df574ae332d57f556fd56314883b3354cab1d0ff.zip | |
cpp conversion: remove useless pj_, PJ_ and proj_ filename prefixes
Diffstat (limited to 'src/deriv.cpp')
| -rw-r--r-- | src/deriv.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/deriv.cpp b/src/deriv.cpp new file mode 100644 index 00000000..0e285265 --- /dev/null +++ b/src/deriv.cpp @@ -0,0 +1,70 @@ +/* dervative of (*P->fwd) projection */ +#define PJ_LIB__ + +#include <math.h> + +#include "projects.h" + +int pj_deriv(LP lp, double h, const PJ *P, struct DERIVS *der) { + XY t; + /* get rid of constness until we can do it for real */ + PJ *Q = (PJ *) P; + if (nullptr==Q->fwd) + return 1; + + lp.lam += h; + lp.phi += h; + if (fabs(lp.phi) > M_HALFPI) + return 1; + + h += h; + t = (*Q->fwd)(lp, Q); + if (t.x == HUGE_VAL) + return 1; + + der->x_l = t.x; + der->y_p = t.y; + der->x_p = t.x; + der->y_l = t.y; + + lp.phi -= h; + if (fabs(lp.phi) > M_HALFPI) + return 1; + + t = (*Q->fwd)(lp, Q); + if (t.x == HUGE_VAL) + return 1; + + der->x_l += t.x; + der->y_p -= t.y; + der->x_p -= t.x; + der->y_l += t.y; + + lp.lam -= h; + t = (*Q->fwd)(lp, Q); + if (t.x == HUGE_VAL) + return 1; + + der->x_l -= t.x; + der->y_p -= t.y; + der->x_p -= t.x; + der->y_l -= t.y; + + lp.phi += h; + t = (*Q->fwd)(lp, Q); + if (t.x == HUGE_VAL) + return 1; + + der->x_l -= t.x; + der->y_p += t.y; + der->x_p += t.x; + der->y_l -= t.y; + + h += h; + der->x_l /= h; + der->y_p /= h; + der->x_p /= h; + der->y_l /= h; + + return 0; +} |
