From 78c1df51e0621a4e0b2314f3af9478627e018db3 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 11 Apr 2020 19:32:50 +0200 Subject: Inverse cart: speed-up computation by 33% Saves 2 sincos() and 1 atan2() calls. With the following bench ``` #include "proj.h" #include #include #include int main(int argc, char* argv[]) { if( argc != 2 ) { fprintf(stderr, "Usage: bench_inv_cart fwd/inv\n"); exit(1); } PJ* p = proj_create(0, "+proj=cart"); const int dir = strcmp(argv[1], "inv") == 0 ? PJ_INV : PJ_FWD; PJ_COORD coord; if( dir == PJ_FWD ) { coord.xyz.x = 3.14159/2; coord.xyz.y = 3.14159/2; coord.xyz.z = 100; } else { coord.xyz.x = 3e6; coord.xyz.y = 3e6; coord.xyz.z = 3e6; } for(int i = 0; i < 10* 1024 * 1024; i++ ) { proj_trans(p, dir, coord); } proj_destroy(p); return 0; } ``` On Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz Time before: 2.37s Time after: 1.57s --- test/gie/more_builtins.gie | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/gie/more_builtins.gie b/test/gie/more_builtins.gie index a3e9d398..323b85c1 100644 --- a/test/gie/more_builtins.gie +++ b/test/gie/more_builtins.gie @@ -840,6 +840,12 @@ expect 180 0 0 accept 0 0 0 expect 0 90 -6356752.314140356 +accept 0 0 1e-6 +expect 0 90 -6356752.314139356 + +accept 0 0 -1e-6 +expect 0 -90 -6356752.314139356 + ------------------------------------------------------------------------------- # Test handling of endianness of NTv2 grids -- cgit v1.2.3