Ejemplo n.º 1
0
        public void CanChangeTransform()
        {
            var s = new TestGeometry();
            var t = Transform.Translate(2, 3, 4);

            s.SetTransform(t);
            s.Transform.Should().Be(t);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 4
0
        public void IntersectingTranslatedShapeWithRay()
        {
            var r = new Ray(new Point(0, 0, -5), new Vector(0, 0, 1));
            var s = new TestGeometry();
            var t = Transform.Translate(5, 0, 0);

            s.SetTransform(t);
            // ReSharper disable once UnusedVariable
            var xs = s.Intersects(r);

            s.SavedRay.Origin.Should().Be(new Point(-5, 0, -5f));
            s.SavedRay.Direction.Should().Be(new Vector(0, 0, 1f));
        }