"Fossies" - the Fresh Open Source Software Archive

Member "proj-6.2.1/src/projections/mbt_fps.cpp" (6 May 2019, 1315 Bytes) of package /linux/privat/proj-6.2.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "mbt_fps.cpp" see the Fossies "Dox" file reference documentation.

    1 #define PJ_LIB__
    2 
    3 #include <math.h>
    4 
    5 #include "proj.h"
    6 #include "proj_internal.h"
    7 
    8 PROJ_HEAD(mbt_fps, "McBryde-Thomas Flat-Pole Sine (No. 2)") "\n\tCyl, Sph";
    9 
   10 #define MAX_ITER    10
   11 #define LOOP_TOL    1e-7
   12 #define C1 0.45503
   13 #define C2 1.36509
   14 #define C3 1.41546
   15 #define C_x 0.22248
   16 #define C_y 1.44492
   17 #define C1_2 0.33333333333333333333333333
   18 
   19 static PJ_XY mbt_fps_s_forward (PJ_LP lp, PJ *P) {           /* Spheroidal, forward */
   20     PJ_XY xy = {0.0,0.0};
   21     double k, V, t;
   22     int i;
   23     (void) P;
   24 
   25     k = C3 * sin(lp.phi);
   26     for (i = MAX_ITER; i ; --i) {
   27         t = lp.phi / C2;
   28         lp.phi -= V = (C1 * sin(t) + sin(lp.phi) - k) /
   29             (C1_2 * cos(t) + cos(lp.phi));
   30         if (fabs(V) < LOOP_TOL)
   31             break;
   32     }
   33     t = lp.phi / C2;
   34     xy.x = C_x * lp.lam * (1. + 3. * cos(lp.phi)/cos(t) );
   35     xy.y = C_y * sin(t);
   36     return xy;
   37 }
   38 
   39 
   40 static PJ_LP mbt_fps_s_inverse (PJ_XY xy, PJ *P) {           /* Spheroidal, inverse */
   41     PJ_LP lp = {0.0,0.0};
   42     double t;
   43 
   44     lp.phi = C2 * (t = aasin(P->ctx,xy.y / C_y));
   45     lp.lam = xy.x / (C_x * (1. + 3. * cos(lp.phi)/cos(t)));
   46     lp.phi = aasin(P->ctx,(C1 * sin(t) + sin(lp.phi)) / C3);
   47     return (lp);
   48 }
   49 
   50 
   51 PJ *PROJECTION(mbt_fps) {
   52 
   53     P->es = 0;
   54     P->inv = mbt_fps_s_inverse;
   55     P->fwd = mbt_fps_s_forward;
   56 
   57     return P;
   58 }