PageRenderTime 27ms CodeModel.GetById 15ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/Proj4/aasincos.c

http://github.com/route-me/route-me
C | 36 lines | 33 code | 2 blank | 1 comment | 5 complexity | 824de4698703f9f1afb798a92399238e MD5 | raw file
 1/* arc sin, cosine, tan2 and sqrt that will NOT fail */
 2#ifndef lint
 3static const char SCCSID[]="@(#)aasincos.c	4.6	93/12/12	GIE	REL";
 4#endif
 5#include "projects.h"
 6#define ONE_TOL	 1.00000000000001
 7#define TOL	0.000000001
 8#define ATOL 1e-50
 9	double
10aasin(double v) {
11	double av;
12
13	if ((av = fabs(v)) >= 1.) {
14		if (av > ONE_TOL)
15			pj_errno = -19;
16		return (v < 0. ? -HALFPI : HALFPI);
17	}
18	return asin(v);
19}
20	double
21aacos(double v) {
22	double av;
23
24	if ((av = fabs(v)) >= 1.) {
25		if (av > ONE_TOL)
26			pj_errno = -19;
27		return (v < 0. ? PI : 0.);
28	}
29	return acos(v);
30}
31	double
32asqrt(double v) { return ((v <= 0) ? 0. : sqrt(v)); }
33	double
34aatan2(double n, double d) {
35	return ((fabs(n) < ATOL && fabs(d) < ATOL) ? 0. : atan2(n,d));
36}