Exemple #1
0
        public void Triangle_IntersectDistance_ray_intersecting_p3_gives_correct_distance()
        {
            Ray ray = new Ray(new Point(1.0f, 1.0f, -10.0f), new Vector(0.0f, 0.0f, 1.0f));
            var p1 = new Point(0.0f, 0.0f, 0.0f);
            var p2 = new Point(1.0f, 0.0f, 0.0f);
            var p3 = new Point(1.0f, 1.0f, 0.0f);
            var t = new Triangle(p1, p2, p3);

            var distance = t.IntersectDistance(ray);

            Assert.AreEqual(10.0f, distance, EPSILON);
        }
Exemple #2
0
        public void Triangle_IntersectDistance_throws_given_null_ray()
        {
            Ray ray = null;
            var p1 = new Point(0.0f, 0.0f, 0.0f);
            var p2 = new Point(1.0f, 0.0f, 0.0f);
            var p3 = new Point(1.0f, 1.0f, 0.0f);
            var t = new Triangle(p1, p2, p3);

            t.IntersectDistance(ray);
        }
Exemple #3
0
        public void Triangle_IntersectDistance_negative_value_given_orthogonal_ray()
        {
            Ray ray = new Ray(new Point(0.0f, 0.0f, -10.0f), new Vector(1.0f, 0.0f, 0.0f));
            var p1 = new Point(0.0f, 0.0f, 0.0f);
            var p2 = new Point(1.0f, 0.0f, 0.0f);
            var p3 = new Point(1.0f, 1.0f, 0.0f);
            var t = new Triangle(p1, p2, p3);

            var distance = t.IntersectDistance(ray);

            Assert.IsTrue(distance < 0.0f);
        }