/Proj4/PJ_oea.c

http://github.com/route-me/route-me · C · 61 lines · 59 code · 2 blank · 0 comment · 3 complexity · efb1d02b9481c856b20243ac4fdc01d0 MD5 · raw file

  1. #ifndef lint
  2. static const char SCCSID[]="@(#)PJ_oea.c 4.1 94/02/15 GIE REL";
  3. #endif
  4. #define PROJ_PARMS__ \
  5. double theta; \
  6. double m, n; \
  7. double two_r_m, two_r_n, rm, rn, hm, hn; \
  8. double cp0, sp0;
  9. #define PJ_LIB__
  10. #include "projects.h"
  11. PROJ_HEAD(oea, "Oblated Equal Area") "\n\tMisc Sph\n\tn= m= theta=";
  12. FORWARD(s_forward); /* sphere */
  13. double Az, M, N, cp, sp, cl, shz;
  14. cp = cos(lp.phi);
  15. sp = sin(lp.phi);
  16. cl = cos(lp.lam);
  17. Az = aatan2(cp * sin(lp.lam), P->cp0 * sp - P->sp0 * cp * cl) + P->theta;
  18. shz = sin(0.5 * aacos(P->sp0 * sp + P->cp0 * cp * cl));
  19. M = aasin(shz * sin(Az));
  20. N = aasin(shz * cos(Az) * cos(M) / cos(M * P->two_r_m));
  21. xy.y = P->n * sin(N * P->two_r_n);
  22. xy.x = P->m * sin(M * P->two_r_m) * cos(N) / cos(N * P->two_r_n);
  23. return (xy);
  24. }
  25. INVERSE(s_inverse); /* sphere */
  26. double N, M, xp, yp, z, Az, cz, sz, cAz;
  27. N = P->hn * aasin(xy.y * P->rn);
  28. M = P->hm * aasin(xy.x * P->rm * cos(N * P->two_r_n) / cos(N));
  29. xp = 2. * sin(M);
  30. yp = 2. * sin(N) * cos(M * P->two_r_m) / cos(M);
  31. cAz = cos(Az = aatan2(xp, yp) - P->theta);
  32. z = 2. * aasin(0.5 * hypot(xp, yp));
  33. sz = sin(z);
  34. cz = cos(z);
  35. lp.phi = aasin(P->sp0 * cz + P->cp0 * sz * cAz);
  36. lp.lam = aatan2(sz * sin(Az),
  37. P->cp0 * cz - P->sp0 * sz * cAz);
  38. return (lp);
  39. }
  40. FREEUP; if (P) pj_dalloc(P); }
  41. ENTRY0(oea)
  42. if (((P->n = pj_param(P->params, "dn").f) <= 0.) ||
  43. ((P->m = pj_param(P->params, "dm").f) <= 0.))
  44. E_ERROR(-39)
  45. else {
  46. P->theta = pj_param(P->params, "rtheta").f;
  47. P->sp0 = sin(P->phi0);
  48. P->cp0 = cos(P->phi0);
  49. P->rn = 1./ P->n;
  50. P->rm = 1./ P->m;
  51. P->two_r_n = 2. * P->rn;
  52. P->two_r_m = 2. * P->rm;
  53. P->hm = 0.5 * P->m;
  54. P->hn = 0.5 * P->n;
  55. P->fwd = s_forward;
  56. P->inv = s_inverse;
  57. P->es = 0.;
  58. }
  59. ENDENTRY(P)