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

/Proj4/PJ_nocol.c

http://github.com/route-me/route-me
C | 41 lines | 40 code | 1 blank | 0 comment | 9 complexity | 3321af5bf85b7e40f34c9d032191de46 MD5 | raw file
 1#ifndef lint
 2static const char SCCSID[]="@(#)PJ_nocol.c	4.1	94/02/15	GIE	REL";
 3#endif
 4#define PJ_LIB__
 5#include	"projects.h"
 6PROJ_HEAD(nicol, "Nicolosi Globular") "\n\tMisc Sph, no inv.";
 7#define EPS	1e-10
 8FORWARD(s_forward); /* spheroid */
 9	if (fabs(lp.lam) < EPS) {
10		xy.x = 0;
11		xy.y = lp.phi;
12	} else if (fabs(lp.phi) < EPS) {
13		xy.x = lp.lam;
14		xy.y = 0.;
15	} else if (fabs(fabs(lp.lam) - HALFPI) < EPS) {
16		xy.x = lp.lam * cos(lp.phi);
17		xy.y = HALFPI * sin(lp.phi);
18	} else if (fabs(fabs(lp.phi) - HALFPI) < EPS) {
19		xy.x = 0;
20		xy.y = lp.phi;
21	} else {
22		double tb, c, d, m, n, r2, sp;
23
24		tb = HALFPI / lp.lam - lp.lam / HALFPI;
25		c = lp.phi / HALFPI;
26		d = (1 - c * c)/((sp = sin(lp.phi)) - c);
27		r2 = tb / d;
28		r2 *= r2;
29		m = (tb * sp / d - 0.5 * tb)/(1. + r2);
30		n = (sp / r2 + 0.5 * d)/(1. + 1./r2);
31		xy.x = cos(lp.phi);
32		xy.x = sqrt(m * m + xy.x * xy.x / (1. + r2));
33		xy.x = HALFPI * ( m + (lp.lam < 0. ? -xy.x : xy.x));
34		xy.y = sqrt(n * n - (sp * sp / r2 + d * sp - 1.) /
35			(1. + 1./r2));
36		xy.y = HALFPI * ( n + (lp.phi < 0. ? xy.y : -xy.y ));
37	}
38	return (xy);
39}
40FREEUP; if (P) pj_dalloc(P); }
41ENTRY0(nicol) P->es = 0.; P->fwd = s_forward; ENDENTRY(P)