Annotation of researchv8dc/cmd/map/libmap/guyou.c, revision 1.1.1.1

1.1       root        1: #include "map.h"
                      2: 
                      3: struct place gywhem, gyehem;
                      4: struct coord gytwist;
                      5: float gyconst, gykc, gyside;
                      6: 
                      7: Xguyou(place,x,y)
                      8: struct place *place;
                      9: float *x, *y;
                     10: {
                     11:        int ew;         /*which hemisphere*/
                     12:        float z1,z2;
                     13:        struct place pl;
                     14:        ew = place->wlon.l<0;
                     15:        copyplace(place,&pl);
                     16:        norm(&pl,ew?&gyehem:&gywhem,&gytwist);
                     17:        Xstereographic(&pl,&z1,&z2);
                     18:        dosquare(z1/2,z2/2,x,y);
                     19:        if(!ew)
                     20:                *x -= gyside;
                     21:        return(1);
                     22: }
                     23: 
                     24: dosquare(z1,z2,x,y)
                     25: float z1,z2;
                     26: float *x,*y;
                     27: {
                     28:        double w1,w2;
                     29:        w1 = z1 -1;
                     30:        if(fabs(w1*w1+z2*z2)>.000001) {
                     31:                cdiv(z1+1,z2,w1,z2,&w1,&w2);
                     32:                w1 *= gyconst;
                     33:                w2 *= gyconst;
                     34:                if(w1<0)
                     35:                        w1 = 0;
                     36:                elco2(w1,w2,gykc,1.,1.,x,y);
                     37:        } else {
                     38:                *x = gyside;
                     39:                *y = 0;
                     40:        }
                     41: }
                     42: 
                     43: int (*guyou())()
                     44: {
                     45:        float junk;
                     46:        gykc = 1/(3+2*sqrt(2.));
                     47:        gyconst = -(1+sqrt(2.));
                     48:        elco2(-gyconst,0.,gykc,1.,1.,&gyside,&junk);
                     49:        gyside *= 2;
                     50:        latlon(0.,90.,&gywhem);
                     51:        latlon(0.,-90.,&gyehem);
                     52:        deg2rad(0.,&gytwist);
                     53:        return(Xguyou);
                     54: }
                     55: 
                     56: guycut(g,og,cutlon)
                     57: struct place *g,*og;
                     58: float *cutlon;
                     59: {
                     60:        int c;
                     61:        c = picut(g,og,cutlon);
                     62:        if(c!=1)
                     63:                return(c);
                     64:        *cutlon = 0.;
                     65:        if(g->nlat.c<.7071||og->nlat.c<.7071)
                     66:                return(ckcut(g,og,0.));
                     67:        return(1);
                     68: }
                     69: 
                     70: Xsquare(place,x,y)
                     71: struct place *place;
                     72: float *x,*y;
                     73: {
                     74:        float z1,z2;
                     75:        float r, theta;
                     76:        struct place p;
                     77:        copyplace(place,&p);
                     78:        if(place->nlat.l<0) {
                     79:                p.nlat.l = -p.nlat.l;
                     80:                p.nlat.s = -p.nlat.s;
                     81:        }
                     82:        if(p.nlat.l<FUZZ && fabs(p.wlon.l)>PI-FUZZ){
                     83:                *y = -gyside/2;
                     84:                *x = p.wlon.l>0?0:gyside;
                     85:                return(1);
                     86:        }
                     87:        Xstereographic(&p,&z1,&z2);
                     88:        r = sqrt(sqrt(hypot(z1,z2)/2));
                     89:        theta = atan2(z1,-z2)/4;
                     90:        dosquare(r*sin(theta),-r*cos(theta),x,y);
                     91:        if(place->nlat.l<0)
                     92:                *y = -gyside - *y;
                     93:        return(1);
                     94: }
                     95: 
                     96: int (*square())()
                     97: {
                     98:        guyou();
                     99:        return(Xsquare);
                    100: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.