1 #include "map.h" 2 3 int 4 Xgilbert(struct place *p, double *x, double *y) 5 { 6 /* the interesting part - map the sphere onto a hemisphere */ 7 struct place q; 8 q.nlat.s = tan(0.5*(p->nlat.l)); 9 if(q.nlat.s > 1) q.nlat.s = 1; 10 if(q.nlat.s < -1) q.nlat.s = -1; 11 q.nlat.c = sqrt(1 - q.nlat.s*q.nlat.s); 12 q.wlon.l = p->wlon.l/2; 13 sincos(&q.wlon); 14 /* the dull part: present the hemisphere orthogrpahically */ 15 *y = q.nlat.s; 16 *x = -q.wlon.s*q.nlat.c; 17 return(1); 18 } 19 20 proj 21 gilbert(void) 22 { 23 return(Xgilbert); 24 } 25 26 /* derivation of the interesting part: 27 map the sphere onto the plane by stereographic projection; 28 map the plane onto a half plane by sqrt; 29 map the half plane back to the sphere by stereographic 30 projection 31 32 n,w are original lat and lon 33 r is stereographic radius 34 primes are transformed versions 35 36 r = cos(n)/(1+sin(n)) 37 r' = sqrt(r) = cos(n')/(1+sin(n')) 38 39 r'^2 = (1-sin(n')^2)/(1+sin(n')^2) = cos(n)/(1+sin(n)) 40 41 this is a linear equation for sin n', with solution 42 43 sin n' = (1+sin(n)-cos(n))/(1+sin(n)+cos(n)) 44 45 use standard formula: tan x/2 = (1-cos x)/sin x = sin x/(1+cos x) 46 to show that the right side of the last equation is tan(n/2) 47 */ 48 49 50