svn-gvsig-desktop / tags / JCRS_V02_BN11 / libjni-proj4 / src / PJ_vandg4.c @ 44492
History | View | Annotate | Download (1.22 KB)
1 |
#ifndef lint
|
---|---|
2 |
static const char SCCSID[]="@(#)PJ_vandg4.c 4.1 94/02/15 GIE REL"; |
3 |
#endif
|
4 |
#define PJ_LIB__
|
5 |
#include <projects.h> |
6 |
PROJ_HEAD(vandg4, "van der Grinten IV") "\n\tMisc Sph, no inv."; |
7 |
#define TOL 1e-10 |
8 |
#define TWORPI 0.63661977236758134308 |
9 |
FORWARD(s_forward); /* spheroid */
|
10 |
double x1, t, bt, ct, ft, bt2, ct2, dt, dt2;
|
11 |
|
12 |
if (fabs(lp.phi) < TOL) {
|
13 |
xy.x = lp.lam; |
14 |
xy.y = 0.;
|
15 |
} else if (fabs(lp.lam) < TOL || fabs(fabs(lp.phi) - HALFPI) < TOL) { |
16 |
xy.x = 0.;
|
17 |
xy.y = lp.phi; |
18 |
} else {
|
19 |
bt = fabs(TWORPI * lp.phi); |
20 |
bt2 = bt * bt; |
21 |
ct = 0.5 * (bt * (8. - bt * (2. + bt2)) - 5.) |
22 |
/ (bt2 * (bt - 1.));
|
23 |
ct2 = ct * ct; |
24 |
dt = TWORPI * lp.lam; |
25 |
dt = dt + 1. / dt;
|
26 |
dt = sqrt(dt * dt - 4.);
|
27 |
if ((fabs(lp.lam) - HALFPI) < 0.) dt = -dt; |
28 |
dt2 = dt * dt; |
29 |
x1 = bt + ct; x1 *= x1; |
30 |
t = bt + 3.*ct;
|
31 |
ft = x1 * (bt2 + ct2 * dt2 - 1.) + (1.-bt2) * ( |
32 |
bt2 * (t * t + 4. * ct2) +
|
33 |
ct2 * (12. * bt * ct + 4. * ct2) ); |
34 |
x1 = (dt*(x1 + ct2 - 1.) + 2.*sqrt(ft)) / |
35 |
(4.* x1 + dt2);
|
36 |
xy.x = HALFPI * x1; |
37 |
xy.y = HALFPI * sqrt(1. + dt * fabs(x1) - x1 * x1);
|
38 |
if (lp.lam < 0.) xy.x = -xy.x; |
39 |
if (lp.phi < 0.) xy.y = -xy.y; |
40 |
} |
41 |
return (xy);
|
42 |
} |
43 |
FREEUP; if (P) pj_dalloc(P); }
|
44 |
ENTRY0(vandg4) P->es = 0.; P->fwd = s_forward; ENDENTRY(P)
|