xref: /plan9/sys/src/cmd/map/libmap/gall.c (revision 219b2ee8daee37f4aad58d63f21287faa8e4ffdc)
1 #include "map.h"
2 
3 static double scale;
4 
5 static int
6 Xgall(struct place *place, double *x, double *y)
7 {
8 	/* two ways to compute tan(place->nlat.l/2) */
9 	if(fabs(place->nlat.s)<.1)
10 		*y = sin(place->nlat.l/2)/cos(place->nlat.l/2);
11 	else
12 		*y = (1-place->nlat.c)/place->nlat.s;
13 	*x = -scale*place->wlon.l;
14 	return 1;
15 }
16 
17 proj
18 gall(double par)
19 {
20 	double coshalf;
21 	if(fabs(par)>80)
22 		return 0;
23 	par *= RAD;
24 	coshalf = cos(par/2);
25 	scale = cos(par)/(2*coshalf*coshalf);
26 	return Xgall;
27 }
28