PageRenderTime 33ms CodeModel.GetById 19ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 1ms

/Proj4/PJ_lagrng.c

http://github.com/route-me/route-me
C | 38 lines | 36 code | 2 blank | 0 comment | 6 complexity | 73c4f7fb4f336f25bcab1165de2f5d11 MD5 | raw file
 1#ifndef lint
 2static const char SCCSID[]="@(#)PJ_lagrng.c	4.1	94/02/15	GIE	REL";
 3#endif
 4#define PROJ_PARMS__ \
 5	double	hrw; \
 6	double	rw; \
 7	double	a1;
 8#define TOL	1e-10
 9#define PJ_LIB__
10#include	"projects.h"
11PROJ_HEAD(lagrng, "Lagrange") "\n\tMisc Sph, no inv.\n\tW=";
12FORWARD(s_forward); /* spheroid */
13	double v, c;
14
15	if (fabs(fabs(lp.phi) - HALFPI) < TOL) {
16		xy.x = 0;
17		xy.y = lp.phi < 0 ? -2. : 2.;
18	} else {
19		lp.phi = sin(lp.phi);
20		v = P->a1 * pow((1. + lp.phi)/(1. - lp.phi), P->hrw);
21		if ((c = 0.5 * (v + 1./v) + cos(lp.lam *= P->rw)) < TOL)
22			F_ERROR;
23		xy.x = 2. * sin(lp.lam) / c;
24		xy.y = (v - 1./v) / c;
25	}
26	return (xy);
27}
28FREEUP; if (P) pj_dalloc(P); }
29ENTRY0(lagrng)
30	double phi1;
31
32	if ((P->rw = pj_param(P->params, "dW").f) <= 0) E_ERROR(-27);
33	P->hrw = 0.5 * (P->rw = 1. / P->rw);
34	phi1 = pj_param(P->params, "rlat_1").f;
35	if (fabs(fabs(phi1 = sin(phi1)) - 1.) < TOL) E_ERROR(-22);
36	P->a1 = pow((1. - phi1)/(1. + phi1), P->hrw);
37	P->es = 0.; P->fwd = s_forward;
38ENDENTRY(P)