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

/Proj4/PJ_mbtfpp.c

http://github.com/route-me/route-me
C | 35 lines | 35 code | 0 blank | 0 comment | 5 complexity | 54510a69d33012bd36133f29024230ad MD5 | raw file
 1#ifndef lint
 2static const char SCCSID[]="@(#)PJ_mbtfpp.c	4.1 94/02/15     GIE     REL";
 3#endif
 4#define PJ_LIB__
 5#include	"projects.h"
 6PROJ_HEAD(mbtfpp, "McBride-Thomas Flat-Polar Parabolic") "\n\tCyl., Sph.";
 7#define CS	.95257934441568037152
 8#define FXC	.92582009977255146156
 9#define FYC	3.40168025708304504493
10#define C23	.66666666666666666666
11#define C13	.33333333333333333333
12#define ONEEPS	1.0000001
13FORWARD(s_forward); /* spheroid */
14	lp.phi = asin(CS * sin(lp.phi));
15	xy.x = FXC * lp.lam * (2. * cos(C23 * lp.phi) - 1.);
16	xy.y = FYC * sin(C13 * lp.phi);
17	return (xy);
18}
19INVERSE(s_inverse); /* spheroid */
20	lp.phi = xy.y / FYC;
21	if (fabs(lp.phi) >= 1.) {
22		if (fabs(lp.phi) > ONEEPS)	I_ERROR
23		else	lp.phi = (lp.phi < 0.) ? -HALFPI : HALFPI;
24	} else
25		lp.phi = asin(lp.phi);
26	lp.lam = xy.x / ( FXC * (2. * cos(C23 * (lp.phi *= 3.)) - 1.) );
27	if (fabs(lp.phi = sin(lp.phi) / CS) >= 1.) {
28		if (fabs(lp.phi) > ONEEPS)	I_ERROR
29		else	lp.phi = (lp.phi < 0.) ? -HALFPI : HALFPI;
30	} else
31		lp.phi = asin(lp.phi);
32	return (lp);
33}
34FREEUP; if (P) pj_dalloc(P); }
35ENTRY0(mbtfpp) P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)