# HG changeset patch # User Alain Mazy # Date 1573142539 -3600 # Node ID 2999a6e9456b824acdded0190a798eeb5cd39284 # Parent f47149cdc0489b7ab9a7399128937bc9166be402 ImageProcessing::ImagePoint::GetDistanceToLine diff -r f47149cdc048 -r 2999a6e9456b Core/Images/ImageProcessing.cpp --- 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(GetX()) + b * static_cast(GetY()) + c) / pow(a * a + b * b, 0.5); + } + template static void ConvertInternal(ImageAccessor& target, const ImageAccessor& source) diff -r f47149cdc048 -r 2999a6e9456b Core/Images/ImageProcessing.h --- a/Core/Images/ImageProcessing.h Thu Nov 07 10:50:50 2019 +0100 +++ b/Core/Images/ImageProcessing.h Thu Nov 07 17:02:19 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,