def test_reduced_circle(self): point_on = Vector2D(1.0, .0) circle = MyCircle(Vector2D(.0, .0), 1.0) self.assertTrue(circle.is_point_on_edge(point_on)) r = 0.75 angle = 3 * pi / 4.0 p0 = Vector2D(r * cos(angle) + 0.25, r * sin(angle)) p1 = Vector2D(-0.5, .0); line = Line2D(circle.centre, point_on) red_circle_new0 = reduced_circle_new(point_on, p0, line) red_circle_new1 = reduced_circle_new(point_on, p1, line) self.assertEqual(0.25, red_circle_new0.centre.get_x()) self.assertEqual(0.0, red_circle_new0.centre.get_y()) self.assertEqual(0.75, red_circle_new0.radius) self.assertEqual(0.25, red_circle_new1.centre.get_x()) self.assertEqual(0.0, red_circle_new1.centre.get_y()) self.assertEqual(0.75, red_circle_new1.radius) self.test_triangle_obtuse() for i in range(500): self.test_random()
def test_random(self): point_on = self.get_random_point() point_centre = self.get_random_point() norm = point_on.sub(point_centre).norm() circle = MyCircle(point_centre, norm) self.assertTrue(circle.is_point_on_edge(point_on)) point_along = self.get_random_point() point_aim = self.get_random_point() new_circle_new = reduced_circle_new(point_on, point_aim, Line2D(circle.centre, point_along)) self.assertTrue(new_circle_new.is_point_on_edge(point_on)) self.assertTrue(new_circle_new.is_point_on_edge(point_aim))