gall.c 512 B

1234567891011121314151617181920212223242526272829
  1. #include <u.h>
  2. #include <libc.h>
  3. #include "map.h"
  4. static double scale;
  5. static int
  6. Xgall(struct place *place, double *x, double *y)
  7. {
  8. /* two ways to compute tan(place->nlat.l/2) */
  9. if(fabs(place->nlat.s)<.1)
  10. *y = sin(place->nlat.l/2)/cos(place->nlat.l/2);
  11. else
  12. *y = (1-place->nlat.c)/place->nlat.s;
  13. *x = -scale*place->wlon.l;
  14. return 1;
  15. }
  16. proj
  17. gall(double par)
  18. {
  19. double coshalf;
  20. if(fabs(par)>80)
  21. return 0;
  22. par *= RAD;
  23. coshalf = cos(par/2);
  24. scale = cos(par)/(2*coshalf*coshalf);
  25. return Xgall;
  26. }