Esempio n. 1
0
        public static bool intersect(VectorLine U, VectorLine V, ref Vector ip)
        {
            if (!U.isLine || !V.isLine)
            {
                return(false);
            }

            Matrix2x2 M   = new Matrix2x2(V.B - V.A, U.A - U.B);
            Vector    Q   = U.A - V.A;
            double    det = M.det;

            if (det == 0)
            {
                return(false); // parallel or overlapping
            }
            Vector st = Matrix2x2.inv(M) * Q;

            if (U.isOnLine(st.y) && V.isOnLine(st.x))
            {
                ip = U.A + (U.B - U.A) * st.y;
                return(true);
            }
            return(false);
        }