Exemplo n.º 1
0
        public void CanFailToInsersectTheBackFaceOfAPolygon()
        {
            // 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.Intersect(ray);

            // Assert
            Assert.IsNull(isect);
        }
Exemplo n.º 2
0
        public void CanInsersectPolygon_Square_NearTopRight()
        {
            // 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.9, 0.9, 0.5), Direction = new Vector(0, 0, -1) };

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

            // Assert
            Assert.NotNull(isect);
            Assert.AreEqual(0.5, isect.Distance);
            Assert.AreEqual(poly, isect.Element);
        }
Exemplo n.º 3
0
        public void CanFailToInsersectPolygon_Square_NegativeMiss()
        {
            // 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.Intersect(ray);

            // Assert
            Assert.IsNull(isect);
        }