Accord.Math.Point3.Collinear C# (CSharp) Method

Collinear() public static method

Gets whether three points lie on the same line.
public static Collinear ( Point3 p1, Point3 p2, Point3 p3 ) : bool
p1 Point3 The first point.
p2 Point3 The second point.
p3 Point3 The third point.
return bool
        public static bool Collinear(Point3 p1, Point3 p2, Point3 p3)
        {
            float x1m2 = p2.X - p1.X;
            float y1m2 = p2.Y - p1.Y;
            float z1m2 = p2.Z - p1.Z;

            float x2m3 = p3.X - p1.X;
            float y2m3 = p3.Y - p1.Y;
            float z2m3 = p3.Z - p1.Z;

            float x = y1m2 * z2m3 - z1m2 * y2m3;
            float y = z1m2 * x2m3 - x1m2 * z2m3;
            float z = x1m2 * y2m3 - y1m2 * x2m3;

            float norm = x * x + y * y + z * z;

            return norm < Constants.SingleEpsilon;
        }