diff --git a/CHANGELOG.md b/CHANGELOG.md index d29dd51d9..4711b4dbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The public API of this library consists of the functions declared in file ### Changed - Replace internal algorithm for `polygonToCells` with a new version that is more memory-efficient (#785) - Reorganize tests into public / internal. (#762) -- Performance enhancement for aarch64, may improve other platforms (#790, #792, #852, #905) +- Performance enhancement for aarch64, may improve other platforms (#790, #792, #852, #905, #913) - `clang-format` upgraded to version 14. (#834) - Fixed tests that incorrectly did not test resolution 15. (#820) - Use `CMAKE_INSTALL_LIBDIR` when choosing where to install library files. (#819) diff --git a/src/h3lib/lib/algos.c b/src/h3lib/lib/algos.c index 949988a08..1b20bf5ef 100644 --- a/src/h3lib/lib/algos.c +++ b/src/h3lib/lib/algos.c @@ -837,12 +837,13 @@ H3Error _getEdgeHexagons(const GeoLoop *geoloop, int64_t numHexagons, int res, } for (int64_t j = 0; j < numHexesEstimate; j++) { LatLng interpolate; + double invNumHexesEst = 1.0 / numHexesEstimate; interpolate.lat = - (origin.lat * (numHexesEstimate - j) / numHexesEstimate) + - (destination.lat * j / numHexesEstimate); + (origin.lat * (numHexesEstimate - j) * invNumHexesEst) + + (destination.lat * j * invNumHexesEst); interpolate.lng = - (origin.lng * (numHexesEstimate - j) / numHexesEstimate) + - (destination.lng * j / numHexesEstimate); + (origin.lng * (numHexesEstimate - j) * invNumHexesEst) + + (destination.lng * j * invNumHexesEst); H3Index pointHex; H3Error e = H3_EXPORT(latLngToCell)(&interpolate, res, &pointHex); if (e) {