xref: /plan9-contrib/sys/src/cmd/map/libmap/fisheye.c (revision 219b2ee8daee37f4aad58d63f21287faa8e4ffdc)
1 #include "map.h"
2 /* refractive fisheye, not logarithmic */
3 
4 static double n;
5 
6 static int
7 Xfisheye(struct place *place, double *x, double *y)
8 {
9 	double r;
10 	double u = sin(PI/4-place->nlat.l/2)/n;
11 	if(fabs(u) > .97)
12 		return -1;
13 	r = tan(asin(u));
14 	*x = -r*place->wlon.s;
15 	*y = -r*place->wlon.c;
16 	return 1;
17 }
18 
19 proj
20 fisheye(double par)
21 {
22 	n = par;
23 	return n<.1? 0: Xfisheye;
24 }
25