Example #1
0
        public void Sphere_IntersectDistance_gives_correct_distance()
        {
            Ray ray = new Ray(new Point(0.0f, -12.0f, 4.2f), new Vector(1.0f, 0.0f, 0.0f));
            var centre = new Point(50.0f, -12.0f, 4.2f);
            var radius = 10.0f;
            var s = new Sphere(centre, radius);

            var distance = s.IntersectDistance(ray);

            Assert.AreEqual(40.0f, distance, EPSILON);
        }
Example #2
0
        public void Sphere_IntersectDistance_negative_value_given_nonintersecting_ray()
        {
            Ray ray = new Ray(new Point(0.0f, 0.0f, 0.0f), new Vector(1.0f, 0.0f, 0.0f));
            var centre = new Point(50.0f, -12.0f, 4.2f);
            var radius = 10.0f;
            var s = new Sphere(centre, radius);

            var distance = s.IntersectDistance(ray);

            Assert.IsTrue(distance < 0.0f);
        }
Example #3
0
        public void Sphere_IntersectDistance_throws_given_null_ray()
        {
            Ray ray = null;
            var centre = new Point(50.0f, -12.0f, 4.2f);
            var radius = 10.0f;
            var s = new Sphere(centre, radius);

            s.IntersectDistance(ray);
        }