~ubuntu-branches/ubuntu/vivid/proj/vivid

« back to all changes in this revision

Viewing changes to src/PJ_eck4.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter S Galbraith
  • Date: 2002-01-11 10:27:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020111102712-ayi18r8y2eesv0y9
Tags: upstream-4.4.5
ImportĀ upstreamĀ versionĀ 4.4.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef lint
 
2
static const char SCCSID[]="@(#)PJ_eck4.c       4.1     94/02/15        GIE     REL";
 
3
#endif
 
4
#define PJ_LIB__
 
5
#include        <projects.h>
 
6
PROJ_HEAD(eck4, "Eckert IV") "\n\tPCyl, Sph.";
 
7
#define C_x     .42223820031577120149
 
8
#define C_y     1.32650042817700232218
 
9
#define RC_y    .75386330736002178205
 
10
#define C_p     3.57079632679489661922
 
11
#define RC_p    .28004957675577868795
 
12
#define EPS     1e-7
 
13
#define NITER   6
 
14
FORWARD(s_forward); /* spheroid */
 
15
        double p, V, s, c;
 
16
        int i;
 
17
 
 
18
        p = C_p * sin(lp.phi);
 
19
        V = lp.phi * lp.phi;
 
20
        lp.phi *= 0.895168 + V * ( 0.0218849 + V * 0.00826809 );
 
21
        for (i = NITER; i ; --i) {
 
22
                c = cos(lp.phi);
 
23
                s = sin(lp.phi);
 
24
                lp.phi -= V = (lp.phi + s * (c + 2.) - p) /
 
25
                        (1. + c * (c + 2.) - s * s);
 
26
                if (fabs(V) < EPS)
 
27
                        break;
 
28
        }
 
29
        if (!i) {
 
30
                xy.x = C_x * lp.lam;
 
31
                xy.y = lp.phi < 0. ? -C_y : C_y;
 
32
        } else {
 
33
                xy.x = C_x * lp.lam * (1. + cos(lp.phi));
 
34
                xy.y = C_y * sin(lp.phi);
 
35
        }
 
36
        return (xy);
 
37
}
 
38
INVERSE(s_inverse); /* spheroid */
 
39
        double c;
 
40
 
 
41
        lp.phi = aasin(xy.y / C_y);
 
42
        lp.lam = xy.x / (C_x * (1. + (c = cos(lp.phi))));
 
43
        lp.phi = aasin((lp.phi + sin(lp.phi) * (c + 2.)) / C_p);
 
44
        return (lp);
 
45
}
 
46
FREEUP; if (P) pj_dalloc(P); }
 
47
ENTRY0(eck4); P->es = 0.; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P)