Example #1
0
        public void NormalsAreNormalized()
        {
            var s = new TestGeometry();
            var n = s.NormalAt(new Point(MathF.Sqrt(3f) / 3f, MathF.Sqrt(3f) / 3f, MathF.Sqrt(3f) / 3f),
                               new Intersection(1f, s));

            (n == n.Normalize()).Should().BeTrue();
        }
Example #2
0
        public void NormalOnTransformedShape()
        {
            var s = new TestGeometry();

            s.SetTransform(Transform.Scale(1f, 0.5f, 1f) * Transform.RotateZ(MathF.PI / 5f));
            var n = s.NormalAt(new Point(0, MathF.Sqrt(2f) / 2f, -MathF.Sqrt(2f) / 2f), new Intersection(1f, s));

            n.Should().Be(new Normal(0, 0.97014f, -0.24254f));
        }
Example #3
0
        public void NormalOnTranslatedShape()
        {
            var s = new TestGeometry();

            s.SetTransform(Transform.Translate(0, 1, 0));
            var n = s.NormalAt(new Point(0, 1.70711f, -0.70711f), new Intersection(1f, s));

            n.Should().Be(new Normal(0, 0.70711f, -0.70711f));
        }