Blob


1 #include <u.h>
2 #include <libc.h>
3 #include "map.h"
5 static double v3,u2,u3,a,b; /*v=view,p=obj,u=unit.y*/
7 static int
8 Xharrison(struct place *place, double *x, double *y)
9 {
10 double p1 = -place->nlat.c*place->wlon.s;
11 double p2 = -place->nlat.c*place->wlon.c;
12 double p3 = place->nlat.s;
13 double d = b + u3*p2 - u2*p3;
14 double t;
15 if(d < .01)
16 return -1;
17 t = a/d;
18 if(v3*place->nlat.s < 1.)
19 return -1;
20 *y = t*p2*u2 + (v3-t*(v3-p3))*u3;
21 *x = t*p1;
22 if(t < 0)
23 return 0;
24 if(*x * *x + *y * *y > 16)
25 return -1;
26 return 1;
27 }
29 proj
30 harrison(double r, double alpha)
31 {
32 u2 = cos(alpha*RAD);
33 u3 = sin(alpha*RAD);
34 v3 = r;
35 b = r*u2;
36 a = 1 + b;
37 if(r<1.001 || a<sqrt(r*r-1))
38 return 0;
39 return Xharrison;
40 }