PageRenderTime 25ms CodeModel.GetById 15ms RepoModel.GetById 0ms 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
  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. if ((av = fabs(v)) >= 1.) {
  13. if (av > ONE_TOL)
  14. pj_errno = -19;
  15. return (v < 0. ? -HALFPI : HALFPI);
  16. }
  17. return asin(v);
  18. }
  19. double
  20. aacos(double v) {
  21. double av;
  22. if ((av = fabs(v)) >= 1.) {
  23. if (av > ONE_TOL)
  24. pj_errno = -19;
  25. return (v < 0. ? PI : 0.);
  26. }
  27. return acos(v);
  28. }
  29. double
  30. asqrt(double v) { return ((v <= 0) ? 0. : sqrt(v)); }
  31. double
  32. aatan2(double n, double d) {
  33. return ((fabs(n) < ATOL && fabs(d) < ATOL) ? 0. : atan2(n,d));
  34. }