gvsig-3d / 1.10 / trunk / libraries / libjni-proj4 / src / aasincos.c @ 76
History | View | Annotate | Download (731 Bytes)
1 | 5 | jzarzoso | /* arc sin, cosine, tan2 and sqrt that will NOT fail */
|
---|---|---|---|
2 | #ifndef lint
|
||
3 | static 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
|
||
10 | aasin(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
|
||
21 | aacos(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
|
||
32 | asqrt(double v) { return ((v <= 0) ? 0. : sqrt(v)); } |
||
33 | double
|
||
34 | aatan2(double n, double d) { |
||
35 | return ((fabs(n) < ATOL && fabs(d) < ATOL) ? 0. : atan2(n,d)); |
||
36 | } |