aboutsummaryrefslogtreecommitdiff
path: root/src/aasincos.c
diff options
context:
space:
mode:
authorKurt Schwehr <schwehr@google.com>2018-05-15 13:42:20 -0700
committerKurt Schwehr <schwehr@google.com>2018-05-15 13:42:20 -0700
commit1e8824517900d37232468b9e3d7f3724e7ffa786 (patch)
tree832a1a4c344cad4d4edfbea9b84adddd63e0001e /src/aasincos.c
parentae40f8d2e407d98b75973dcbe4eb4cf5d3cb87a3 (diff)
downloadPROJ-1e8824517900d37232468b9e3d7f3724e7ffa786.tar.gz
PROJ-1e8824517900d37232468b9e3d7f3724e7ffa786.zip
IWYU: Partial PJ_natearth.c..rtodms.c
Diffstat (limited to 'src/aasincos.c')
-rw-r--r--src/aasincos.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/aasincos.c b/src/aasincos.c
index c3915613..4f9ea25f 100644
--- a/src/aasincos.c
+++ b/src/aasincos.c
@@ -1,34 +1,38 @@
/* arc sin, cosine, tan2 and sqrt that will NOT fail */
+
+#include <math.h>
+
#include "projects.h"
+
#define ONE_TOL 1.00000000000001
#define ATOL 1e-50
- double
+ double
aasin(projCtx ctx,double v) {
- double av;
-
- if ((av = fabs(v)) >= 1.) {
- if (av > ONE_TOL)
+ double av;
+
+ if ((av = fabs(v)) >= 1.) {
+ if (av > ONE_TOL)
pj_ctx_set_errno( ctx, PJD_ERR_ACOS_ASIN_ARG_TOO_LARGE );
- return (v < 0. ? -M_HALFPI : M_HALFPI);
- }
- return asin(v);
+ return (v < 0. ? -M_HALFPI : M_HALFPI);
+ }
+ return asin(v);
}
- double
+ double
aacos(projCtx ctx, double v) {
- double av;
+ double av;
- if ((av = fabs(v)) >= 1.) {
- if (av > ONE_TOL)
+ if ((av = fabs(v)) >= 1.) {
+ if (av > ONE_TOL)
pj_ctx_set_errno( ctx, PJD_ERR_ACOS_ASIN_ARG_TOO_LARGE );
- return (v < 0. ? M_PI : 0.);
- }
- return acos(v);
+ return (v < 0. ? M_PI : 0.);
+ }
+ return acos(v);
}
- double
+ double
asqrt(double v) { return ((v <= 0) ? 0. : sqrt(v)); }
- double
+ double
aatan2(double n, double d) {
- return ((fabs(n) < ATOL && fabs(d) < ATOL) ? 0. : atan2(n,d));
+ return ((fabs(n) < ATOL && fabs(d) < ATOL) ? 0. : atan2(n,d));
}