xref: /plan9/sys/src/cmd/map/libmap/polyconic.c (revision 59cc4ca53493a3c6d2349fe2b7f7c40f7dce7294)
1 #include <u.h>
2 #include <libc.h>
3 #include "map.h"
4 
5 int
Xpolyconic(struct place * place,double * x,double * y)6 Xpolyconic(struct place *place, double *x, double *y)
7 {
8 	double r, alpha;
9 	double lat2, lon2;
10 	if(fabs(place->nlat.l) > .01) {
11 		r = place->nlat.c / place->nlat.s;
12 		alpha = place->wlon.l * place->nlat.s;
13 		*y = place->nlat.l + r*(1 - cos(alpha));
14 		*x = - r*sin(alpha);
15 	} else {
16 		lon2 = place->wlon.l * place->wlon.l;
17 		lat2 = place->nlat.l * place->nlat.l;
18 		*y = place->nlat.l * (1+(lon2/2)*(1-(8+lon2)*lat2/12));
19 		*x = - place->wlon.l * (1-lat2*(3+lon2)/6);
20 	}
21 	return(1);
22 }
23 
24 proj
polyconic(void)25 polyconic(void)
26 {
27 	return(Xpolyconic);
28 }
29