Exemplo n.º 1
0
        public void TestColorWhenRayMisses()
        {
            var w = new DefaultWorld();
            var r = new Ray(Vector4.CreatePosition(0, 0, -5), Vector4.CreateDirection(0, 1, 0));
            var c = w.Trace(r, 5);

            Assert.Equal(Color.Black, c);
        }
Exemplo n.º 2
0
        public void TestColorWhenRayHits()
        {
            var          w        = new DefaultWorld();
            var          r        = new Ray(Vector4.CreatePosition(0, 0, -5), Vector4.CreateDirection(0, 0, 1));
            var          c        = w.Trace(r, 5);
            var          expected = new Color(0.38066, 0.47583, 0.2855);
            const double eps      = 0.00001;
            var          comparer = Color.GetEqualityComparer(eps);

            Assert.Equal(expected, c, comparer);
        }
Exemplo n.º 3
0
        public void TestColorWithIntersectionBehindRay()
        {
            var w     = new DefaultWorld();
            var outer = w.Objects[0];

            outer.Material.Ambient = 1;
            var inner = w.Objects[1];

            inner.Material.Ambient = 1;
            var          r        = new Ray(Vector4.CreatePosition(0, 0, 0.75), Vector4.CreateDirection(0, 0, -1));
            var          c        = w.Trace(r, 5);
            const double eps      = 0.00001;
            var          comparer = Color.GetEqualityComparer(eps);

            Assert.Equal(inner.Material.Color, c, comparer);
        }