Пример #1
0
        public void CanCalculateNormalToPlane()
        {
            // Arrange
            var plane = new Plane() { Point = new Vector(0, 0, 0), Norm = new Vector(0, 1, 0) };

            // Act
            var normal = plane.Normal(new Vector(0, 2,2));

            // Assert
            Assert.IsTrue(normal.Equals(new Vector(0, 1, 0)));
        }
Пример #2
0
        public void CanFailToIntersectWhenRayParallelToPlane()
        {
            // Arrange
            var plane = new Plane() { Point = new Vector(0, 0, 0), Norm = new Vector(0, 1, 0) };
            var ray = new Ray() { Start = new Vector(0, 1, 0), Direction = new Vector(1, 0, 0) };

            // Act
            var isect = plane.Intersect(ray);

            // Assert
            Assert.IsNull(isect);
        }
Пример #3
0
        public void CanInsersectPlane()
        {
            // Arrange
            var plane = new Plane() { Point = new Vector(0, 0, 0), Norm = new Vector(0, 1, 0) };
            var ray = new Ray() { Start = new Vector(0, 1, 0), Direction = new Vector(0, -1, 0) };

            // Act
            var isect = plane.Intersect(ray);

            // Assert
            Assert.NotNull(isect);
            Assert.AreEqual(1, isect.Distance);
            Assert.AreEqual(plane, isect.Element);
        }