plan9port

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

trapezoidal.c (578B)


      1 #include <u.h>
      2 #include <libc.h>
      3 #include "map.h"
      4 
      5 static struct coord stdpar0, stdpar1;
      6 static double k;
      7 static double yeq;
      8 
      9 static int
     10 Xtrapezoidal(struct place *place, double *x, double *y)
     11 {
     12 	*y = yeq + place->nlat.l;
     13 	*x = *y*k*place->wlon.l;
     14 	return 1;
     15 }
     16 
     17 proj
     18 trapezoidal(double par0, double par1)
     19 {
     20 	if(fabs(fabs(par0)-fabs(par1))<.1)
     21 		return rectangular(par0);
     22 	deg2rad(par0,&stdpar0);
     23 	deg2rad(par1,&stdpar1);
     24 	if(fabs(par1-par0) < .1)
     25 		k = stdpar1.s;
     26 	else
     27 		k = (stdpar1.c-stdpar0.c)/(stdpar0.l-stdpar1.l);
     28 	yeq = -stdpar1.l - stdpar1.c/k;
     29 	return Xtrapezoidal;
     30 }