You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.
float s = dets / denominator;
float t = dett / denominator;
//The points of intersection.
Vector3 point1 = ray1.Position + (s * ray1.Direction);
Vector3 point2 = ray2.Position + (t * ray2.Direction);
both s and t should be non-negative numbers because rays have a starting point.
I had to add this code after computing s and t.
if (s < 0 || t < 0)
{
point = Vector3.Zero;
return false;
}
Also, I added the else in this section when the Rays are parallel but not on top of each other:
//Lines are parallel.
if (MathUtil.IsZero(denominator))
{
//Lines are parallel and on top of each other.
if (MathUtil.NearEqual(ray2.Position.X, ray1.Position.X) &&
MathUtil.NearEqual(ray2.Position.Y, ray1.Position.Y) &&
MathUtil.NearEqual(ray2.Position.Z, ray1.Position.Z))
{
point = Vector3.Zero;
return true;
}
else
{
point = Vector3.Zero;
return false;
}
}
The text was updated successfully, but these errors were encountered:
When finding the intersection point:
both s and t should be non-negative numbers because rays have a starting point.
I had to add this code after computing s and t.
Also, I added the else in this section when the Rays are parallel but not on top of each other:
The text was updated successfully, but these errors were encountered: