/Proj4/pj_phi2.c

http://github.com/route-me/route-me · C · 28 lines · 24 code · 3 blank · 1 comment · 3 complexity · 384399f443a6d51866535412b08c44a5 MD5 · raw file

  1. /* determine latitude angle phi-2 */
  2. #ifndef lint
  3. static const char SCCSID[]="@(#)pj_phi2.c 4.3 93/06/12 GIE REL";
  4. #endif
  5. #include "projects.h"
  6. #define HALFPI 1.5707963267948966
  7. #define TOL 1.0e-10
  8. #define N_ITER 15
  9. double
  10. pj_phi2(double ts, double e) {
  11. double eccnth, Phi, con, dphi;
  12. int i;
  13. eccnth = .5 * e;
  14. Phi = HALFPI - 2. * atan (ts);
  15. i = N_ITER;
  16. do {
  17. con = e * sin (Phi);
  18. dphi = HALFPI - 2. * atan (ts * pow((1. - con) /
  19. (1. + con), eccnth)) - Phi;
  20. Phi += dphi;
  21. } while ( fabs(dphi) > TOL && --i);
  22. if (i <= 0)
  23. pj_errno = -18;
  24. return Phi;
  25. }