Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }