diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-04-14 18:13:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-14 18:13:59 +0200 |
| commit | 5d94742cd774b5e6f8d45043a01f8c69dcbbe73c (patch) | |
| tree | dcf0be23b887bd1c36602cc225245082caa0692e | |
| parent | 43d11bd830932ef18770a53e72fc93f67b3d137c (diff) | |
| parent | 97366a706c4d25ebb671810b78d70be184a4899d (diff) | |
| download | PROJ-5d94742cd774b5e6f8d45043a01f8c69dcbbe73c.tar.gz PROJ-5d94742cd774b5e6f8d45043a01f8c69dcbbe73c.zip | |
Merge pull request #2147 from rouault/speedup_again_fwd_extented_tmerc
Extended tmerc: speed-up forward path by ~5%
| -rw-r--r-- | src/projections/tmerc.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/projections/tmerc.cpp b/src/projections/tmerc.cpp index 91dad135..6787ed72 100644 --- a/src/projections/tmerc.cpp +++ b/src/projections/tmerc.cpp @@ -390,7 +390,9 @@ static PJ_XY exact_e_fwd (PJ_LP lp, PJ *P) { * cos(2 * Cn) = 2cos^2(Cn) - 1 * = 2 / (1 + tan_Cn^2) - 1 */ - const double tmp_r = 2 * cos_Cn_cos_Ce * inv_denom_tan_Ce * inv_denom_tan_Ce; + const double two_inv_denom_tan_Ce = 2 * inv_denom_tan_Ce; + const double two_inv_denom_tan_Ce_square = two_inv_denom_tan_Ce * inv_denom_tan_Ce; + const double tmp_r = cos_Cn_cos_Ce * two_inv_denom_tan_Ce_square; const double sin_arg_r = sin_Cn * tmp_r; const double cos_arg_r = cos_Cn_cos_Ce * tmp_r - 1; @@ -407,10 +409,15 @@ static PJ_XY exact_e_fwd (PJ_LP lp, PJ *P) { * * cosh(2 * Ce) = 2cosh^2(Ce) - 1 * = 2 * (1 + tan_Ce^2) - 1 + * + * and 1+tan_Ce^2 = 1 + sin_Ce^2 * cos_Cn^2 / (sin_Cn^2 + cos_Cn^2 * cos_Ce^2) + * = (sin_Cn^2 + cos_Cn^2 * cos_Ce^2 + sin_Ce^2 * cos_Cn^2) / (sin_Cn^2 + cos_Cn^2 * cos_Ce^2) + * = 1. / (sin_Cn^2 + cos_Cn^2 * cos_Ce^2) + * = inv_denom_tan_Ce^2 + * */ - const double tmp_i = 1 + tan_Ce * tan_Ce; - const double sinh_arg_i = 2 * tan_Ce * sqrt(tmp_i); - const double cosh_arg_i = 2 * tmp_i - 1; + const double sinh_arg_i = tan_Ce * two_inv_denom_tan_Ce; + const double cosh_arg_i = two_inv_denom_tan_Ce_square - 1; double dCn, dCe; Cn += clenS (Q->gtu, PROJ_ETMERC_ORDER, |
