Ejemplo n.º 1
0
        public void CanFindPointOfIntersection()
        {
            // Arrange
            var points = new List<Vector>() { new Vector(0, 0, 0), new Vector(1, 0, 0), new Vector(1, 1, 0), new Vector(0, 1, 0) };
            var poly = new Polygon(points, new Vector(0, 0, 1));

            var ray = new Ray() { Start = new Vector(0.5, 0.5, 0.5), Direction = new Vector(0, 0, -1) };

            // Act
            var isect = poly.GetPointOfIntersectionWithPlane(ray);

            // Assert
            Assert.NotNull(isect);
            Assert.AreEqual(0.5, isect.X);
            Assert.AreEqual(0.5, isect.Y);
        }
Ejemplo n.º 2
0
        public void CanFailToIntersectPlaneWithParallelRay()
        {
            // Arrange
            var points = new List<Vector>() { new Vector(0, 0, 0), new Vector(1, 0, 0), new Vector(1, 1, 0), new Vector(0, 1, 0) };
            var poly = new Polygon(points, new Vector(0, 0, 1));

            var ray = new Ray() { Start = new Vector(1, 0, 0.5), Direction = new Vector(1, 0, 0) };

            // Act
            var isect = poly.GetPointOfIntersectionWithPlane(ray);

            // Assert
            Assert.IsNull(isect);
        }