Check it out on Wikipedia:
https://en.wikipedia.org/wiki/Collinearity
I assume that with your method, you wish to check whether the three given points are collinear or not?
I cannot comment on your implementation and am unsure wether the built-in Revit API method will provide exactly what you need.
I would suggest implementing such a check yourself; it will be more effective and you will know exactly what is going on and why.
Here are some solution suggestions:
https://www.geeksforgeeks.org/program-check-three-points-collinear/
The Building Coder samples already includes a predicate checking for collinear lines:
/// <summary>
/// Predicate returning true if two given lines are collinear
/// </summary>
public static bool IsCollinear( Line a, Line b )
{
XYZ v = a.Direction;
XYZ w = b.Origin - a.Origin;
return IsParallel( v, b.Direction )
&& IsParallel( v, w );
}
I added a new method to check for collinear points as well:
/// <summary>
/// Predicate returning true if three given points are collinear
/// </summary>
public static bool AreCollinear( XYZ p, XYZ q, XYZ r )
{
XYZ v = q - p;
XYZ w = r - p;
return IsParallel( v, w );
}
Basically, this method considers the three points as corners of a triangle, determines the vectors from one of them to the two others, and reports whether these two vectors are parallel.
Please try it out and let us know whether that satisfies your requirements.
Here is the diff to the previous release:
https://github.com/jeremytammik/the_building_coder_samples/compare/2022.0.151.0...2022.0.151.1
Best regards,
Jeremy