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