proj lune(double lat, double theta) { deg2rad(lat, &eastpole.nlat); deg2rad(-90.,&eastpole.wlon); deg2rad(lat, &westpole.nlat); deg2rad(90. ,&westpole.wlon); Xstereographic(&eastpole, &eastx, &easty); Xstereographic(&westpole, &westx, &westy); if(fabs(easty)>FUZZ || fabs(westy)>FUZZ || fabs(eastx+westx)>FUZZ) abort(); scale = 1/eastx; pwr = theta/180; return Xlune; }
static int Xlune(struct place *place, double *x, double *y) { double stereox, stereoy; double z1x, z1y, z2x, z2y; double w1x, w1y, w2x, w2y; double numx, numy, denx, deny; if(place->nlat.l < eastpole.nlat.l-FUZZ) return -1; Xstereographic(place, &stereox, &stereoy); stereox *= scale; stereoy *= scale; z1x = 1 + stereox; z1y = stereoy; z2x = 1 - stereox; z2y = -stereoy; cpow(z1x,z1y,&w1x,&w1y,pwr); cpow(z2x,z2y,&w2x,&w2y,pwr); numx = w1x - w2x; numy = w1y - w2y; denx = w1x + w2x; deny = w1y + w2y; cdiv(numx, numy, denx, deny, x, y); return 1; }
static int Xhex(struct place *place, double *x, double *y) { int ns; int i; double zr,zi; double sr,si,tr,ti,ur,ui,vr,vi,yr,yi; struct place p; copyplace(place,&p); ns = place->nlat.l >= 0; if(!ns) { p.nlat.l = -p.nlat.l; p.nlat.s = -p.nlat.s; } if(p.nlat.l<HFUZZ) { for(i=0;i<3;i++) if(fabs(reduce(p.wlon.l-hcut[i]))<HFUZZ) { if(i==2) { *x = 2*cr[0] - cr[1]; *y = 0; } else { *x = cr[1]; *y = 2*ci[2*i]; } return(1); } p.nlat.l = HFUZZ; sincos(&p.nlat); } norm(&p,&hem,&twist); Xstereographic(&p,&zr,&zi); zr /= 2; zi /= 2; cdiv(1-zr,-zi,1+zr,zi,&sr,&si); csq(sr,si,&tr,&ti); ccubrt(1+3*tr,3*ti,&ur,&ui); csqrt(ur-1,ui,&vr,&vi); cdiv(rootroot3+vr,vi,rootroot3-vr,-vi,&yr,&yi); yr /= rootk; yi /= rootk; elco2(fabs(yr),yi,hkc,1.,1.,x,y); if(yr < 0) *x = w2 - *x; if(!ns) reflect(hcut[0]>place->wlon.l?0: hcut[1]>=place->wlon.l?1: 2,*x,*y,x,y); return(1); }
int Xtetra(struct place *place, double *x, double *y) { int i,j; struct place pl; register struct tproj *tpp; double vr, vi; double br, bi; double zr,zi,z2r,z2i,z4r,z4i,sr,si,tr,ti; twhichp(place,&i,&j); copyplace(place,&pl); norm(&pl,&tproj[i][j].projpl,&tproj[i][j].projtw); Xstereographic(&pl,&vr,&vi); zr = vr/2; zi = vi/2; if(zr<=TFUZZ) zr = TFUZZ; csq(zr,zi,&z2r,&z2i); csq(z2r,z2i,&z4r,&z4i); z2r *= two_rt3; z2i *= two_rt3; cdiv(z4r+z2r-1,z4i+z2i,z4r-z2r-1,z4i-z2i,&sr,&si); csqrt(sr-1,si,&tr,&ti); cdiv(tcon*tr,tcon*ti,root3+1-sr,-si,&br,&bi); if(br<0) { br = -br; bi = -bi; if(!elco2(br,bi,tk,1.,1.,&vr,&vi)) return 0; vr = fpir - vr; vi = fpii - vi; } else if(!elco2(br,bi,tk,1.,1.,&vr,&vi)) return 0; if(si>=0) { tr = f0r - vi; ti = f0i + vr; } else { tr = f0r + vi; ti = f0i - vr; } tpp = &tproj[i][j]; *x = tr*tpp->postrot.c + ti*tpp->postrot.s + tx[i]; *y = ti*tpp->postrot.c - tr*tpp->postrot.s + ty[i]; return(1); }