PageRenderTime 32ms CodeModel.GetById 16ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/Proj4/PJ_eck4.c

http://github.com/route-me/route-me
C | 47 lines | 45 code | 2 blank | 0 comment | 5 complexity | a6d24e3fbfe0f994db7dff15595f2caf MD5 | raw file
 1#ifndef lint
 2static const char SCCSID[]="@(#)PJ_eck4.c	4.1	94/02/15	GIE	REL";
 3#endif
 4#define PJ_LIB__
 5#include	"projects.h"
 6PROJ_HEAD(eck4, "Eckert IV") "\n\tPCyl, Sph.";
 7#define C_x	.42223820031577120149
 8#define C_y	1.32650042817700232218
 9#define RC_y	.75386330736002178205
10#define C_p	3.57079632679489661922
11#define RC_p	.28004957675577868795
12#define EPS	1e-7
13#define NITER	6
14FORWARD(s_forward); /* spheroid */
15	double p, V, s, c;
16	int i;
17
18	p = C_p * sin(lp.phi);
19	V = lp.phi * lp.phi;
20	lp.phi *= 0.895168 + V * ( 0.0218849 + V * 0.00826809 );
21	for (i = NITER; i ; --i) {
22		c = cos(lp.phi);
23		s = sin(lp.phi);
24		lp.phi -= V = (lp.phi + s * (c + 2.) - p) /
25			(1. + c * (c + 2.) - s * s);
26		if (fabs(V) < EPS)
27			break;
28	}
29	if (!i) {
30		xy.x = C_x * lp.lam;
31		xy.y = lp.phi < 0. ? -C_y : C_y;
32	} else {
33		xy.x = C_x * lp.lam * (1. + cos(lp.phi));
34		xy.y = C_y * sin(lp.phi);
35	}
36	return (xy);
37}
38INVERSE(s_inverse); /* spheroid */
39	double c;
40
41	lp.phi = aasin(xy.y / C_y);
42	lp.lam = xy.x / (C_x * (1. + (c = cos(lp.phi))));
43	lp.phi = aasin((lp.phi + sin(lp.phi) * (c + 2.)) / C_p);
44	return (lp);
45}
46FREEUP; if (P) pj_dalloc(P); }
47ENTRY0(eck4); P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)