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