PageRenderTime 27ms CodeModel.GetById 18ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Proj4/PJ_eck2.c

http://github.com/route-me/route-me
C | 31 lines | 31 code | 0 blank | 0 comment | 5 complexity | 94bd3e0bb9e2fcd1ba69100bb04aa537 MD5 | raw file
 1#ifndef lint
 2static const char SCCSID[]="@(#)PJ_eck2.c	4.1 94/02/15     GIE     REL";
 3#endif
 4#define PJ_LIB__
 5# include	"projects.h"
 6PROJ_HEAD(eck2, "Eckert II") "\n\tPCyl. Sph.";
 7#define FXC	0.46065886596178063902
 8#define FYC	1.44720250911653531871
 9#define C13	0.33333333333333333333
10#define ONEEPS	1.0000001
11FORWARD(s_forward); /* spheroid */
12	xy.x = FXC * lp.lam * (xy.y = sqrt(4. - 3. * sin(fabs(lp.phi))));
13	xy.y = FYC * (2. - xy.y);
14	if ( lp.phi < 0.) xy.y = -xy.y;
15	return (xy);
16}
17INVERSE(s_inverse); /* spheroid */
18	lp.lam = xy.x / (FXC * ( lp.phi = 2. - fabs(xy.y) / FYC) );
19	lp.phi = (4. - lp.phi * lp.phi) * C13;
20	if (fabs(lp.phi) >= 1.) {
21		if (fabs(lp.phi) > ONEEPS)	I_ERROR
22		else
23			lp.phi = lp.phi < 0. ? -HALFPI : HALFPI;
24	} else
25		lp.phi = asin(lp.phi);
26	if (xy.y < 0)
27		lp.phi = -lp.phi;
28	return (lp);
29}
30FREEUP; if (P) pj_dalloc(P); }
31ENTRY0(eck2); P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)