PageRenderTime 18ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/Proj4/PJ_fouc_s.c

http://github.com/route-me/route-me
C | 48 lines | 46 code | 2 blank | 0 comment | 7 complexity | c30ebab0f1da09140f96f3685b57ddec MD5 | raw file
  1. #ifndef lint
  2. static const char SCCSID[]="@(#)PJ_fouc_s.c 4.1 94/02/15 GIE REL";
  3. #endif
  4. #define PROJ_PARMS__ \
  5. double n, n1;
  6. #define PJ_LIB__
  7. #include "projects.h"
  8. PROJ_HEAD(fouc_s, "Foucaut Sinusoidal") "\n\tPCyl., Sph.";
  9. #define MAX_ITER 10
  10. #define LOOP_TOL 1e-7
  11. FORWARD(s_forward); /* spheroid */
  12. double t;
  13. t = cos(lp.phi);
  14. xy.x = lp.lam * t / (P->n + P->n1 * t);
  15. xy.y = P->n * lp.phi + P->n1 * sin(lp.phi);
  16. return (xy);
  17. }
  18. INVERSE(s_inverse); /* spheroid */
  19. double V;
  20. int i;
  21. if (P->n) {
  22. lp.phi = xy.y;
  23. for (i = MAX_ITER; i ; --i) {
  24. lp.phi -= V = (P->n * lp.phi + P->n1 * sin(lp.phi) - xy.y ) /
  25. (P->n + P->n1 * cos(lp.phi));
  26. if (fabs(V) < LOOP_TOL)
  27. break;
  28. }
  29. if (!i)
  30. lp.phi = xy.y < 0. ? -HALFPI : HALFPI;
  31. } else
  32. lp.phi = aasin(xy.y);
  33. V = cos(lp.phi);
  34. lp.lam = xy.x * (P->n + P->n1 * V) / V;
  35. return (lp);
  36. }
  37. FREEUP; if (P) pj_dalloc(P); }
  38. ENTRY0(fouc_s)
  39. P->n = pj_param(P->params, "dn").f;
  40. if (P->n < 0. || P->n > 1.)
  41. E_ERROR(-99)
  42. P->n1 = 1. - P->n;
  43. P->es = 0;
  44. P->inv = s_inverse;
  45. P->fwd = s_forward;
  46. ENDENTRY(P)