PageRenderTime 22ms CodeModel.GetById 12ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/Proj4/PJ_boggs.c

http://github.com/route-me/route-me
C | 35 lines | 34 code | 1 blank | 0 comment | 5 complexity | 28f799b7d226ce44f46aec18807f1565 MD5 | raw file
 1#ifndef lint
 2static const char SCCSID[]="@(#)PJ_boggs.c	4.1 94/02/15     GIE     REL";
 3#endif
 4#define PJ_LIB__
 5# include	"projects.h"
 6PROJ_HEAD(boggs, "Boggs Eumorphic") "\n\tPCyl., no inv., Sph.";
 7# define NITER	20
 8# define EPS	1e-7
 9# define ONETOL 1.000001
10# define FXC	2.00276
11# define FXC2	1.11072
12# define FYC	0.49931
13# define FYC2	1.41421356237309504880
14FORWARD(s_forward); /* spheroid */
15	double theta, th1, c;
16	int i;
17
18	theta = lp.phi;
19	if (fabs(fabs(lp.phi) - HALFPI) < EPS)
20		xy.x = 0.;
21	else {
22		c = sin(theta) * PI;
23		for (i = NITER; i; --i) {
24			theta -= th1 = (theta + sin(theta) - c) /
25				(1. + cos(theta));
26			if (fabs(th1) < EPS) break;
27		}
28		theta *= 0.5;
29		xy.x = FXC * lp.lam / (1. / cos(lp.phi) + FXC2 / cos(theta));
30	}
31	xy.y = FYC * (lp.phi + FYC2 * sin(theta));
32	return (xy);
33}
34FREEUP; if (P) pj_dalloc(P); }
35ENTRY0(boggs) P->es = 0.; P->fwd = s_forward; ENDENTRY(P)