lagrange.c 468 B

123456789101112131415161718192021222324252627282930
  1. #include <u.h>
  2. #include <libc.h>
  3. #include "map.h"
  4. static int
  5. Xlagrange(struct place *place, double *x, double *y)
  6. {
  7. double z1,z2;
  8. double w1,w2,t1,t2;
  9. struct place p;
  10. copyplace(place,&p);
  11. if(place->nlat.l<0) {
  12. p.nlat.l = -p.nlat.l;
  13. p.nlat.s = -p.nlat.s;
  14. }
  15. Xstereographic(&p,&z1,&z2);
  16. csqrt(-z2/2,z1/2,&w1,&w2);
  17. cdiv(w1-1,w2,w1+1,w2,&t1,&t2);
  18. *y = -t1;
  19. *x = t2;
  20. if(place->nlat.l<0)
  21. *y = -*y;
  22. return(1);
  23. }
  24. proj
  25. lagrange(void)
  26. {
  27. return(Xlagrange);
  28. }