PageRenderTime 12ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/Proj4/PJ_nell_h.c

http://github.com/route-me/route-me
C | 33 lines | 32 code | 1 blank | 0 comment | 4 complexity | 0635d053547b2a6de4a674553605e31d MD5 | raw file
  1. #ifndef lint
  2. static const char SCCSID[]="@(#)PJ_nell_h.c 4.1 94/02/15 GIE REL";
  3. #endif
  4. #define PJ_LIB__
  5. # include "projects.h"
  6. PROJ_HEAD(nell_h, "Nell-Hammer") "\n\tPCyl., Sph.";
  7. #define NITER 9
  8. #define EPS 1e-7
  9. FORWARD(s_forward); /* spheroid */
  10. xy.x = 0.5 * lp.lam * (1. + cos(lp.phi));
  11. xy.y = 2.0 * (lp.phi - tan(0.5 *lp.phi));
  12. return (xy);
  13. }
  14. INVERSE(s_inverse); /* spheroid */
  15. double V, c, p;
  16. int i;
  17. p = 0.5 * xy.y;
  18. for (i = NITER; i ; --i) {
  19. c = cos(0.5 * lp.phi);
  20. lp.phi -= V = (lp.phi - tan(lp.phi/2) - p)/(1. - 0.5/(c*c));
  21. if (fabs(V) < EPS)
  22. break;
  23. }
  24. if (!i) {
  25. lp.phi = p < 0. ? -HALFPI : HALFPI;
  26. lp.lam = 2. * xy.x;
  27. } else
  28. lp.lam = 2. * xy.x / (1. + cos(lp.phi));
  29. return (lp);
  30. }
  31. FREEUP; if (P) pj_dalloc(P); }
  32. ENTRY0(nell_h) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)