public void IntersectInsideSphereTest() { var ray = Helper.Ray(Helper.CreatePoint(0, 0, 0), Helper.CreateVector(0, 0, 1)); var sphere = Helper.Sphere(); var xs = new Intersections(); sphere.Intersect(ref ray.Origin, ref ray.Direction, xs); Check.That(xs.Select(i => i.T)).ContainsExactly(-1, 1); Check.That(xs.Select(i => i.Object)).ContainsExactly(sphere, sphere); }
public void IntersectSphereBehindRayTest() { var ray = Helper.Ray(Helper.CreatePoint(0, 0, 5), Helper.CreateVector(0, 0, 1)); var sphere = Helper.Sphere(); var xs = new Intersections(); sphere.Intersect(ref ray.Origin, ref ray.Direction, xs); Check.That(xs.Select(i => i.T)).ContainsExactly(-6, -4); }
public void WorldIntersectsTest() { var world = GetDefaultWorld(); var ray = Helper.Ray(Helper.CreatePoint(0, 0, -5), Helper.CreateVector(0, 0, 1)); var intersections = new Intersections(); world.Intersect(ray, intersections); Check.That(intersections.Select(intersection => intersection.T)).ContainsExactly(4, 4.5, 5.5, 6); }
public void IntersectScaledTest() { var ray = Helper.Ray(Helper.CreatePoint(0, 0, -5), Helper.CreateVector(0, 0, 1)); var sphere = Helper.Sphere(); sphere.Transform = Helper.Scaling(2, 2, 2); var xs = new Intersections(); sphere.Intersect(ref ray.Origin, ref ray.Direction, xs); Check.That(xs.Select(i => i.T)).ContainsExactly(3, 7); }