plan9port

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

simpleconic.c (644B)


      1 #include <u.h>
      2 #include <libc.h>
      3 #include "map.h"
      4 
      5 static double r0, a;
      6 
      7 static int
      8 Xsimpleconic(struct place *place, double *x, double *y)
      9 {
     10 	double r = r0 - place->nlat.l;
     11 	double t = a*place->wlon.l;
     12 	*x = -r*sin(t);
     13 	*y = -r*cos(t);
     14 	return 1;
     15 }
     16 
     17 proj
     18 simpleconic(double par0, double par1)
     19 {
     20 	struct coord lat0;
     21 	struct coord lat1;
     22 	deg2rad(par0,&lat0);
     23 	deg2rad(par1,&lat1);
     24 	if(fabs(lat0.l+lat1.l)<.01)
     25 		return rectangular(par0);
     26 	if(fabs(lat0.l-lat1.l)<.01) {
     27 		a = lat0.s/lat0.l;
     28 		r0 = lat0.c/lat0.s + lat0.l;
     29 	} else {
     30 		a = (lat1.c-lat0.c)/(lat0.l-lat1.l);
     31 		r0 = ((lat0.c+lat1.c)/a + lat1.l + lat0.l)/2;
     32 	}
     33 	return Xsimpleconic;
     34 }