public RayAABBSerfaceIntersection IntersectionTest(AABBSurface surface) { RayAABBSerfaceIntersection result = new RayAABBSerfaceIntersection(); double distance = origin.ToArray()[(int)surface.axis] - surface.location; double speed = direction.ToArray()[(int)surface.axis]; if (distance == 0 || speed == 0) { return(result); } double zoom = distance / speed; if (zoom <= 0) { return(result); } result.ray = this; result.surface = surface; result.IsIntersect = true; result.distance = direction.Magnitude * zoom; result.HitPoint = direction * zoom + origin; return(result); }
public RayAABBSerfaceIntersection() { ray = null; surface = null; IsIntersect = false; distance = 0; HitPoint = null; }