PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Proj4/PJ_nell_h.c

http://github.com/route-me/route-me
C | 33 lines | 32 code | 1 blank | 0 comment | 4 complexity | 0635d053547b2a6de4a674553605e31d MD5 | raw file
 1#ifndef lint
 2static const char SCCSID[]="@(#)PJ_nell_h.c	4.1	94/02/15	GIE	REL";
 3#endif
 4#define PJ_LIB__
 5# include	"projects.h"
 6PROJ_HEAD(nell_h, "Nell-Hammer") "\n\tPCyl., Sph.";
 7#define NITER 9
 8#define EPS 1e-7
 9FORWARD(s_forward); /* spheroid */
10	xy.x = 0.5 * lp.lam * (1. + cos(lp.phi));
11	xy.y = 2.0 * (lp.phi - tan(0.5 *lp.phi));
12	return (xy);
13}
14INVERSE(s_inverse); /* spheroid */
15	double V, c, p;
16	int i;
17
18	p = 0.5 * xy.y;
19	for (i = NITER; i ; --i) {
20		c = cos(0.5 * lp.phi);
21		lp.phi -= V = (lp.phi - tan(lp.phi/2) - p)/(1. - 0.5/(c*c));
22		if (fabs(V) < EPS)
23			break;
24	}
25	if (!i) {
26		lp.phi = p < 0. ? -HALFPI : HALFPI;
27		lp.lam = 2. * xy.x;
28	} else
29		lp.lam = 2. * xy.x / (1. + cos(lp.phi));
30	return (lp);
31}
32FREEUP; if (P) pj_dalloc(P); }
33ENTRY0(nell_h) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)