public void ARayMissesACSGObject()
        {
            var c  = new CSG(Operation.UNION, new Sphere(), new Cube());
            var r  = new Ray(new Point(0, 2, -5), new Vector(0, 0, 1));
            var xs = c.Intersects(r);

            Assert.AreEqual(0, xs.Count);
        }
        public void IntersectingRayAndCsgTestsChildrenIfBoxIsHit()
        {
            var left  = new TestShape();
            var right = new TestShape();
            var shape = new CSG(Operation.DIFFERENCE, left, right);
            var r     = new Ray(new Point(0, 0, -5), new Vector(0, 0, 1));
            var xs    = shape.Intersects(r);

            Assert.IsNotNull(left.SavedRay);
            Assert.IsNotNull(right.SavedRay);
        }
        public void ARayHitsACSGObject()
        {
            var s1 = new Sphere();
            var s2 = new Sphere
            {
                Transform = Transform.Translation(0, 0, 0.5)
            };

            var c  = new CSG(Operation.UNION, s1, s2);
            var r  = new Ray(new Point(0, 0, -5), new Vector(0, 0, 1));
            var xs = c.Intersects(r);

            Assert.AreEqual(2, xs.Count);
            Assert.AreEqual(4, xs[0].T);
            Assert.AreEqual(s1, xs[0].Shape);
            Assert.AreEqual(6.5, xs[1].T);
            Assert.AreEqual(s2, xs[1].Shape);
        }