1 /*
2 ** libproj -- library of cartographic projections
3 **
4 ** Copyright (c) 2003, 2005, 2006   Gerald I. Evenden
5 */
6 static const char
7 LIBPROJ_ID[] = "Id";
8 /*
9 ** Permission is hereby granted, free of charge, to any person obtaining
10 ** a copy of this software and associated documentation files (the
11 ** "Software"), to deal in the Software without restriction, including
12 ** without limitation the rights to use, copy, modify, merge, publish,
13 ** distribute, sublicense, and/or sell copies of the Software, and to
14 ** permit persons to whom the Software is furnished to do so, subject to
15 ** the following conditions:
16 **
17 ** The above copyright notice and this permission notice shall be
18 ** included in all copies or substantial portions of the Software.
19 **
20 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 */
28 #define PROJ_LIB__
29 #define PROJ_PARMS__\
30   int  sym;
31 #include  <lib_proj.h>
32 PROJ_HEAD(hatano, "Hatano Equal Area") "\n\tPCyl, Sph.\n[tsym=]";
33 #define NITER  20
34 #define EPS  1e-7
35 #define ONETOL 1.000001
36 #define CN  2.67595
37 #define CS  2.43763
38 #define RCN  0.37369906014686373063
39 #define RCS  0.41023453108141924738
40 #define FYCN  1.75859
41 #define FYCS  1.93052
42 #define RYCN  0.56863737426006061674
43 #define RYCS  0.51799515156538134803
44 #define FXC  0.85
45 #define RXC  1.17647058823529411764
46 FORWARD(s_forward); /* spheroid */
47   double th1, c;
48   int i, opt = !P->sym && (lp.phi < 0.);
49 
50   c = sin(lp.phi) * (opt ? CS : CN);
51   for (i = NITER; i; --i) {
52     lp.phi -= th1 = (lp.phi + sin(lp.phi) - c) / (1. + cos(lp.phi));
53     if (fabs(th1) < EPS) break;
54   }
55   xy.x = FXC * lp.lam * cos(lp.phi *= .5);
56   xy.y = sin(lp.phi) * (opt ? FYCS : FYCN);
57   return (xy);
58 }
59 INVERSE(s_inverse); /* spheroid */
60   double th;
61   int opt = !P->sym && (xy.y < 0.);
62 
63   th = xy.y * ( opt ? RYCS : RYCN);
64   if (fabs(th) > 1.)
65     if (fabs(th) > ONETOL)  I_ERROR
66     else      th = th > 0. ? HALFPI : - HALFPI;
67   else
68     th = asin(th);
69   lp.lam = RXC * xy.x / cos(th);
70   th += th;
71   lp.phi = (th + sin(th)) * (opt ? RCS : RCN);
72   if (fabs(lp.phi) > 1.)
73     if (fabs(lp.phi) > ONETOL)  I_ERROR
74     else      lp.phi = lp.phi > 0. ? HALFPI : - HALFPI;
75   else
76     lp.phi = asin(lp.phi);
77   return (lp);
78 }
79 FREEUP; if (P) free(P); }
80 ENTRY0(hatano)
81   P->sym = proj_param(P->params, "tsym").i;
82   P->es = 0.;
83   P->inv = s_inverse;
84   P->fwd = s_forward;
85 ENDENTRY(P)
86 /*
87 ** Log: proj_hatano.c
88 ** Revision 3.1  2006/01/11 01:38:18  gie
89 ** Initial
90 **
91 */
92