diff Core/Images/ImageProcessing.cpp @ 3565:2999a6e9456b

ImageProcessing::ImagePoint::GetDistanceToLine
author Alain Mazy <alain@mazy.be>
date Thu, 07 Nov 2019 17:02:19 +0100
parents 0f5f9a5eed25
children 113a9643e8bb
line wrap: on
line diff
--- a/Core/Images/ImageProcessing.cpp	Thu Nov 07 10:50:50 2019 +0100
+++ b/Core/Images/ImageProcessing.cpp	Thu Nov 07 17:02:19 2019 +0100
@@ -56,6 +56,11 @@
     return sqrt(dx * dx + dy * dy);
   }
 
+  double ImageProcessing::ImagePoint::GetDistanceToLine(double a, double b, double c) const // where ax + by + c = 0 is the equation of the line
+  {
+    return std::abs(a * static_cast<double>(GetX()) + b * static_cast<double>(GetY()) + c) / pow(a * a + b * b, 0.5);
+  }
+
   template <typename TargetType, typename SourceType>
   static void ConvertInternal(ImageAccessor& target,
                               const ImageAccessor& source)