diff options
| author | Charles Karney <charles.karney@sri.com> | 2020-10-26 18:29:19 -0400 |
|---|---|---|
| committer | Charles Karney <charles.karney@sri.com> | 2020-10-26 18:29:19 -0400 |
| commit | 75a8436b2491dbc1eebb196ea42b961fd011a52e (patch) | |
| tree | 4e43de3a122c7ddf163e89dcf386bc72d239619a /src/projections/merc.cpp | |
| parent | ee35d15db597801a86314dc8a47da7de10c9d8f2 (diff) | |
| download | PROJ-75a8436b2491dbc1eebb196ea42b961fd011a52e.tar.gz PROJ-75a8436b2491dbc1eebb196ea42b961fd011a52e.zip | |
Use sincos optimization in merc_e_forward. Revised timing data...
Times per call in ns = nanoseconds.
Fedora 31 Ubuntu 18
g++-9.3.1 g++-7.5.0
fwd inv fwd inv
old merc 207 461 217 522
new merc 159 457 137 410
etmerc 212 196 174 147
The new forward method is now 25% faster (resp 35% faster) on Fedora
31 (resp Ubuntu 18). The new inverse method is the same speed (resp 20%
faster) on Fedora 31 (resp Ubuntu 18).
The accuracy is hardly affected: rms error increases from 0.30 nm to
0.33 nm, max error increases from 1.83 nm to 1.84 nm (a barely
noticeable degradation).
Diffstat (limited to 'src/projections/merc.cpp')
| -rw-r--r-- | src/projections/merc.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/projections/merc.cpp b/src/projections/merc.cpp index 472cb43f..e5da3967 100644 --- a/src/projections/merc.cpp +++ b/src/projections/merc.cpp @@ -13,7 +13,8 @@ PROJ_HEAD(webmerc, "Web Mercator / Pseudo Mercator") "\n\tCyl, Ell\n\t"; static PJ_XY merc_e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forward */ PJ_XY xy = {0.0,0.0}; xy.x = P->k0 * lp.lam; - xy.y = P->k0 * (asinh(tan(lp.phi)) - P->e * atanh(P->e * sin(lp.phi))); + double sphi = sin(lp.phi), cphi = cos(lp.phi); + xy.y = P->k0 * (asinh(sphi/cphi) - P->e * atanh(P->e * sphi)); return xy; } |
