TerrainDisplay.Collision.Intersection.IntersectionOfTwoLines C# (CSharp) Method

IntersectionOfTwoLines() public static method

public static IntersectionOfTwoLines ( System.Vector3 a, System.Vector3 b, System.Vector3 c, System.Vector3 d, System.Vector3 &result ) : bool
a System.Vector3
b System.Vector3
c System.Vector3
d System.Vector3
result System.Vector3
return bool
        public static bool IntersectionOfTwoLines(Vector3 a, Vector3 b, Vector3 c, Vector3 d, ref Vector3 result)
        {
            double num3 = ((b.X - a.X) * (d.Y - c.Y)) - ((b.Y - a.Y) * (d.X - c.X));
            if (num3 == 0.0)
            {
                return false;
            }
            double num4 = ((a.Y - c.Y) * (d.X - c.X)) - ((a.X - c.X) * (d.Y - c.Y));
            var num = num4 / num3;
            double num5 = ((a.Y - c.Y) * (b.X - a.X)) - ((a.X - c.X) * (b.Y - a.Y));
            var num2 = num5 / num3;
            if ((((num < 0.0) || (num > 1.0)) || (num2 < 0.0)) || (num2 > 1.0))
            {
                return false;
            }
            result.X = a.X + ((float)(num * (b.X - a.X)));
            result.Y = a.Y + ((float)(num * (b.Y - a.Y)));
            return true;
        }