Esempio n. 1
0
        internal static bool LineSegmentIntersection(Vector2_d p1, Vector2_d p2, Vector2_d p3, Vector2_d p4, ref Vector2_d result)
        {
            double num1 = p2.x - p1.x;
            double num2 = p2.y - p1.y;
            double num3 = p4.x - p3.x;
            double num4 = p4.y - p3.y;
            double num5 = (num1 * num4 - num2 * num3);

            if (num5 == 0.0)
            {
                return(false);
            }
            double num6 = p3.x - p1.x;
            double num7 = p3.y - p1.y;
            double num8 = (num6 * num4 - num7 * num3) / num5;

            if (num8 < 0.0 || num8 > 1.0)
            {
                return(false);
            }
            double num9 = (num6 * num2 - num7 * num1) / num5;

            if (num9 < 0.0 || num9 > 1.0)
            {
                return(false);
            }
            result = new Vector2_d(p1.x + num8 * num1, p1.y + num8 * num2);
            return(true);
        }
Esempio n. 2
0
 public Vector4_d(Vector2_d v2)
 {
     x = v2.x;
     y = v2.y;
     z = 0.0;
     w = 0.0;
 }