public static bool IntersectSegmentPlane(Vector3 a, Vector3 b, Plane p, ref float t, ref Vector3 q) { var vector = b - a; t = (p.D - Vector3.Dot(p.Normal, a)) / Vector3.Dot(p.Normal, vector); if ((t >= 0f) && (t <= 1f)) { q = a + (t * vector); return true; } return false; }