mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 07:19:22 +02:00
LazUtils/Graphmath: Fix incorrect Distance() function for vertical lines. Issue #41098
This commit is contained in:
parent
6d66b7be1d
commit
6ca87f810b
@ -689,10 +689,8 @@ var
|
|||||||
|
|
||||||
function Slope(PT1,Pt2 : TFloatPoint) : Extended;
|
function Slope(PT1,Pt2 : TFloatPoint) : Extended;
|
||||||
begin
|
begin
|
||||||
If Pt2.X <> Pt1.X then
|
// The case Pt1.X = Pt2.X has already been handled.
|
||||||
Result := (Pt2.Y - Pt1.Y) / (Pt2.X - Pt1.X)
|
Result := (Pt2.Y - Pt1.Y) / (Pt2.X - Pt1.X);
|
||||||
else
|
|
||||||
Result := 1;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function YIntercept(PT1,Pt2 : TFloatPoint) : Extended;
|
function YIntercept(PT1,Pt2 : TFloatPoint) : Extended;
|
||||||
@ -701,6 +699,15 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
if SP.X = EP.X then
|
||||||
|
begin
|
||||||
|
if SP.Y <> EP.Y then
|
||||||
|
Result := abs(Pt.X - SP.X)
|
||||||
|
else
|
||||||
|
Result := Distance(Pt, SP);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
A := -Slope(SP,EP);
|
A := -Slope(SP,EP);
|
||||||
B := 1;
|
B := 1;
|
||||||
C := -YIntercept(SP, EP);
|
C := -YIntercept(SP, EP);
|
||||||
|
Loading…
Reference in New Issue
Block a user