plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

lagrange.c (468B)


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