changeset 3566:ee508761d753

merge
author Alain Mazy <alain@mazy.be>
date Fri, 08 Nov 2019 17:34:54 +0100
parents 2999a6e9456b (diff) 4812825e69fc (current diff)
children 8b8edb26d4c1
files
diffstat 2 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Images/ImageProcessing.cpp	Thu Nov 07 15:35:18 2019 +0100
+++ b/Core/Images/ImageProcessing.cpp	Fri Nov 08 17:34:54 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)
--- a/Core/Images/ImageProcessing.h	Thu Nov 07 15:35:18 2019 +0100
+++ b/Core/Images/ImageProcessing.h	Fri Nov 08 17:34:54 2019 +0100
@@ -72,6 +72,8 @@
       }
 
       double GetDistanceTo(const ImagePoint& other) const;
+
+      double GetDistanceToLine(double a, double b, double c) const; // where ax + by + c = 0 is the equation of the line
     };
 
     void Copy(ImageAccessor& target,