From d25924b571acd83b99dcb2bd4607a5f2b8564ba1 Mon Sep 17 00:00:00 2001 From: Ryan Friedman Date: Wed, 20 Mar 2024 18:11:11 +0000 Subject: [PATCH] Add TODO for optimization to avoid sqrt Signed-off-by: Ryan Friedman --- alg/los.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/alg/los.cpp b/alg/los.cpp index ce3d77cbb9e9..da62f9c72248 100644 --- a/alg/los.cpp +++ b/alg/los.cpp @@ -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(rNum) / static_cast(rDenom)); return lerp(zA, zB, ratio);