Skip to content

Commit

Permalink
Add TODO for optimization to avoid sqrt
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Friedman <[email protected]>
  • Loading branch information
Ryan Friedman committed Mar 20, 2024
1 parent b9ebc37 commit d25924b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions alg/los.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ bool GDALIsLineOfSightVisible(const GDALRasterBandH hBand, const int xA,
{
const auto rNum = SQUARE(x - xA) + SQUARE(y - yA);
const auto rDenom = SQUARE(xB - xA) + SQUARE(yB - yA);
/// @todo In order to reduce CPU cost and avoid a sqrt operation, consider
/// the approach to just the ratio along x or y depending on whether
/// the line is steep or shallow.
/// See https://github.com/OSGeo/gdal/pull/9506#discussion_r1532459689.
const double ratio =
sqrt(static_cast<double>(rNum) / static_cast<double>(rDenom));
return lerp(zA, zB, ratio);
Expand Down

0 comments on commit d25924b

Please sign in to comment.