/// <summary> /// /// </summary> /// <param name="u"></param> /// <param name="v"></param> /// <param name="w"></param> /// <param name="tu"></param> /// <param name="tv"></param> private static bool LineLineIntersection(Vec2d u, Vec2d v, Vec2d w, out double tu, out double tv) { // impl ref // https://www.codeproject.com/Tips/862988/Find-the-Intersection-Point-of-Two-Line-Segments var c = Vec2d.Cross(u, v); if (Math.Abs(c) > 0.0) { c = 1.0 / c; tu = Vec2d.Cross(w, v) * c; tv = Vec2d.Cross(w, u) * c; return(true); } // lines are parallel, no solution tu = tv = 0.0; return(false); }