From df574ae332d57f556fd56314883b3354cab1d0ff Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 19 Dec 2018 13:00:37 +0100 Subject: cpp conversion: remove useless pj_, PJ_ and proj_ filename prefixes --- src/qsfn.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/qsfn.cpp (limited to 'src/qsfn.cpp') diff --git a/src/qsfn.cpp b/src/qsfn.cpp new file mode 100644 index 00000000..c18a7b95 --- /dev/null +++ b/src/qsfn.cpp @@ -0,0 +1,22 @@ +/* determine small q */ +#include +#include "projects.h" + +# define EPSILON 1.0e-7 + +double pj_qsfn(double sinphi, double e, double one_es) { + double con, div1, div2; + + if (e >= EPSILON) { + con = e * sinphi; + div1 = 1.0 - con * con; + div2 = 1.0 + con; + + /* avoid zero division, fail gracefully */ + if (div1 == 0.0 || div2 == 0.0) + return HUGE_VAL; + + return (one_es * (sinphi / div1 - (.5 / e) * log ((1. - con) / div2 ))); + } else + return (sinphi + sinphi); +} -- cgit v1.2.3