private static IntersectSegmentPlane ( Vector3 a, Vector3 b, Plane p, Vector3 &q ) : bool | ||
a | Vector3 | |
b | Vector3 | |
p | Plane | |
q | Vector3 | |
Результат | bool |
private static bool IntersectSegmentPlane(Vector3 a, Vector3 b, Plane p, out Vector3 q)
{
Vector3 ab = b - a;
float d = (p.D - Vector3.Dot(p.Normal, a)) / Vector3.Dot(p.Normal, ab);
if (d >= 0 && d <= 1)
{
q = a + d * ab;
return true;
}
q = Vector3.Zero;
return false;
}