6 static double cirmod(double);
8 static struct place pole; /* map pole is tilted to here */
9 static struct coord twist; /* then twisted this much */
10 static struct place ipole; /* inverse transfrom */
11 static struct coord itwist;
14 orient(double lat, double lon, double theta)
21 } else if(lat < -90.) {
26 latlon(lat,lon,&pole);
27 deg2rad(theta, &twist);
28 latlon(lat,180.-theta,&ipole);
29 deg2rad(180.-lon, &itwist);
33 latlon(double lat, double lon, struct place *p)
39 } else if(lat < -90.) {
43 deg2rad(lat,&p->nlat);
44 deg2rad(lon,&p->wlon);
48 deg2rad(double theta, struct coord *coord)
50 theta = cirmod(theta);
55 } else if(theta== -90) {
73 sincos(struct coord *coord)
75 coord->s = sin(coord->l);
76 coord->c = cos(coord->l);
80 normalize(struct place *gg)
82 norm(gg,&pole,&twist);
86 invert(struct place *g)
88 norm(g,&ipole,&itwist);
92 norm(struct place *gg, struct place *pp, struct coord *tw)
94 register struct place *g; /*geographic coords */
95 register struct place *p; /* new pole in old coords*/
96 struct place m; /* standard map coords*/
100 if(p->wlon.l+tw->l == 0.)
102 g->wlon.l -= p->wlon.l+tw->l;
105 g->wlon.l -= p->wlon.l;
108 m.nlat.s = p->nlat.s * g->nlat.s
109 + p->nlat.c * g->nlat.c * g->wlon.c;
110 m.nlat.c = sqrt(1. - m.nlat.s * m.nlat.s);
111 m.nlat.l = atan2(m.nlat.s, m.nlat.c);
112 m.wlon.s = g->nlat.c * g->wlon.s;
113 m.wlon.c = p->nlat.c * g->nlat.s
114 - p->nlat.s * g->nlat.c * g->wlon.c;
115 m.wlon.l = atan2(m.wlon.s, - m.wlon.c)
122 else if(g->wlon.l<-PI)
127 printp(struct place *g)
129 printf("%.3f %.3f %.3f %.3f %.3f %.3f\n",
130 g->nlat.l,g->nlat.s,g->nlat.c,g->wlon.l,g->wlon.s,g->wlon.c);
134 copyplace(struct place *g1, struct place *g2)