PageRenderTime 86ms CodeModel.GetById 74ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/Proj4/PJ_vandg2.c

http://github.com/route-me/route-me
C | 48 lines | 47 code | 1 blank | 0 comment | 8 complexity | eb0c2b47697ace890fa151116e35b09d MD5 | raw file
 1#ifndef lint
 2static const char SCCSID[]="@(#)PJ_vandg2.c	4.1	94/02/15	GIE	REL";
 3#endif
 4# define TOL	1e-10
 5# define TWORPI	0.63661977236758134308
 6#define PROJ_PARMS__ \
 7	int	vdg3;
 8#define PJ_LIB__
 9#include	"projects.h"
10PROJ_HEAD(vandg2, "van der Grinten II") "\n\tMisc Sph, no inv.";
11PROJ_HEAD(vandg3, "van der Grinten III") "\n\tMisc Sph, no inv.";
12FORWARD(s_forward); /* spheroid */
13	double x1, at, bt, ct;
14
15	bt = fabs(TWORPI * lp.phi);
16	if ((ct = 1. - bt * bt) < 0.)
17		ct = 0.;
18	else
19		ct = sqrt(ct);
20	if (fabs(lp.lam) < TOL) {
21		xy.x = 0.;
22		xy.y = PI * (lp.phi < 0. ? -bt : bt) / (1. + ct);
23	} else {
24		at = 0.5 * fabs(PI / lp.lam - lp.lam / PI);
25		if (P->vdg3) {
26			x1 = bt / (1. + ct);
27			xy.x = PI * (sqrt(at * at + 1. - x1 * x1) - at);
28			xy.y = PI * x1;
29		} else {
30			x1 = (ct * sqrt(1. + at * at) - at * ct * ct) /
31				(1. + at * at * bt * bt);
32			xy.x = PI * x1;
33			xy.y = PI * sqrt(1. - x1 * (x1 + 2. * at) + TOL);
34		}
35		if ( lp.lam < 0.) xy.x = -xy.x;
36		if ( lp.phi < 0.) xy.y = -xy.y;
37	}
38	return (xy);
39}
40FREEUP; if (P) pj_dalloc(P); }
41ENTRY0(vandg2)
42	P->vdg3 = 0;
43	P->inv = 0; P->fwd = s_forward;
44ENDENTRY(P)
45ENTRY0(vandg3)
46	P->vdg3 = 1;
47	P->es = 0.; P->fwd = s_forward;
48ENDENTRY(P)