I am trying to check when 3 points (double) are collinear in 2-D. I found various Pascal functions that return true if checked; these functions use an integer to indicate the X and Y coordinates. I need a more accurate calculation up to at least the first three digits of the decimal part of X and Y, expressed as a double type. Who can help me?
I found this function:
function Collinear(x1, y1, x2, y2, x3, y3: Double): Boolean; begin Result := (((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)) = 0); end;
But I think the calculation will never be 0. Should I use something like this?
function Collinear(x1, y1, x2, y2, x3, y3: Double): Boolean; begin Result := (((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)) < 0.01); end;
geometry delphi delphi-2009 pascal
marcostT
source share