fisheye.c 407 B

1234567891011121314151617181920212223242526
  1. #include <u.h>
  2. #include <libc.h>
  3. #include "map.h"
  4. /* refractive fisheye, not logarithmic */
  5. static double n;
  6. static int
  7. Xfisheye(struct place *place, double *x, double *y)
  8. {
  9. double r;
  10. double u = sin(PI/4-place->nlat.l/2)/n;
  11. if(fabs(u) > .97)
  12. return -1;
  13. r = tan(asin(u));
  14. *x = -r*place->wlon.s;
  15. *y = -r*place->wlon.c;
  16. return 1;
  17. }
  18. proj
  19. fisheye(double par)
  20. {
  21. n = par;
  22. return n<.1? 0: Xfisheye;
  23. }