PageRenderTime 35ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/Proj4/PJ_lagrng.c

http://github.com/route-me/route-me
C | 38 lines | 36 code | 2 blank | 0 comment | 6 complexity | 73c4f7fb4f336f25bcab1165de2f5d11 MD5 | raw file
  1. #ifndef lint
  2. static const char SCCSID[]="@(#)PJ_lagrng.c 4.1 94/02/15 GIE REL";
  3. #endif
  4. #define PROJ_PARMS__ \
  5. double hrw; \
  6. double rw; \
  7. double a1;
  8. #define TOL 1e-10
  9. #define PJ_LIB__
  10. #include "projects.h"
  11. PROJ_HEAD(lagrng, "Lagrange") "\n\tMisc Sph, no inv.\n\tW=";
  12. FORWARD(s_forward); /* spheroid */
  13. double v, c;
  14. if (fabs(fabs(lp.phi) - HALFPI) < TOL) {
  15. xy.x = 0;
  16. xy.y = lp.phi < 0 ? -2. : 2.;
  17. } else {
  18. lp.phi = sin(lp.phi);
  19. v = P->a1 * pow((1. + lp.phi)/(1. - lp.phi), P->hrw);
  20. if ((c = 0.5 * (v + 1./v) + cos(lp.lam *= P->rw)) < TOL)
  21. F_ERROR;
  22. xy.x = 2. * sin(lp.lam) / c;
  23. xy.y = (v - 1./v) / c;
  24. }
  25. return (xy);
  26. }
  27. FREEUP; if (P) pj_dalloc(P); }
  28. ENTRY0(lagrng)
  29. double phi1;
  30. if ((P->rw = pj_param(P->params, "dW").f) <= 0) E_ERROR(-27);
  31. P->hrw = 0.5 * (P->rw = 1. / P->rw);
  32. phi1 = pj_param(P->params, "rlat_1").f;
  33. if (fabs(fabs(phi1 = sin(phi1)) - 1.) < TOL) E_ERROR(-22);
  34. P->a1 = pow((1. - phi1)/(1. + phi1), P->hrw);
  35. P->es = 0.; P->fwd = s_forward;
  36. ENDENTRY(P)