elliptic.c 627 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <u.h>
  2. #include <libc.h>
  3. #include "map.h"
  4. struct coord center;
  5. static int
  6. Xelliptic(struct place *place, double *x, double *y)
  7. {
  8. double r1,r2;
  9. r1 = acos(place->nlat.c*(place->wlon.c*center.c
  10. - place->wlon.s*center.s));
  11. r2 = acos(place->nlat.c*(place->wlon.c*center.c
  12. + place->wlon.s*center.s));
  13. *x = -(r1*r1 - r2*r2)/(4*center.l);
  14. *y = (r1*r1+r2*r2)/2 - (center.l*center.l+*x**x);
  15. if(*y < 0)
  16. *y = 0;
  17. *y = sqrt(*y);
  18. if(place->nlat.l<0)
  19. *y = -*y;
  20. return(1);
  21. }
  22. proj
  23. elliptic(double l)
  24. {
  25. l = fabs(l);
  26. if(l>89)
  27. return(0);
  28. if(l<1)
  29. return(Xazequidistant);
  30. deg2rad(l,&center);
  31. return(Xelliptic);
  32. }