Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization in getEdgeHexagons #913

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Optimization in getEdgeHexagons
Replace 4 fpdiv's with 1 fpdiv and 4 fpmul's
  • Loading branch information
heshpdx committed Sep 26, 2024
commit bae3394457a23a0e7a9c0d2b56727f1fd16f1680
9 changes: 5 additions & 4 deletions src/h3lib/lib/algos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading