Esempio n. 1
0
 def test_find_arc_intersection_with_circles_that_do_not_intersect(self):
     arc1 = Arc(Point(1, 0), 90, 1, 180)
     arc2 = Arc(Point(10, 10), 180, 2, 270)
     self.assertEqual(arc1._find_arc_intersection(arc2), [])
     # with nested circles
     arc3 = Arc(Point(6, 0), 0, 4, 360)
     arc4 = Arc(Point(6, 1), 0, 2, 360)
     self.assertEqual(arc3._find_arc_intersection(arc4), [])
Esempio n. 2
0
 def test_find_arc_intersection_with_arcs_that_intersect_at_two_points(
         self):
     # with the center of each circle outside the other circle
     arc1 = Arc(Point(5, 0), 90, 5, 60)
     arc2 = Arc(Point(8, -1), 180, 5, -90)
     self.assertAlmostEqual(arc1._find_arc_intersection(arc2),
                            [Point(5, 0), Point(3, 4)])
     # with the center of one of the circles inside the other circle
     arc3 = Arc(Point(0, 5), 180, 5, 180)
     arc4 = Arc(Point(-1, 0), 90, 3, 270)
     self.assertAlmostEqual(arc3._find_arc_intersection(arc4),
                            [Point(-4, 3), Point(-4, -3)])
Esempio n. 3
0
 def test_find_arc_intersection_with_arcs_that_intersect_at_one_point(self):
     # with positive angular length and circles that intersect at two points
     arc1 = Arc(Point(5, 0), 90, 5, 360)
     arc2 = Arc(Point(0, 3), 0, 5, 45)
     self.assertAlmostEqual(arc1._find_arc_intersection(arc2),
                            [Point(3, 4)])
     # with negative angular length and circles that intersect at two points
     arc3 = Arc(Point(0, 4), 0, 4, -135)
     arc4 = Arc(Point(4, 0), 180, 4, 360)
     self.assertEqual(arc3._find_arc_intersection(arc4), [Point(4, 0)])
     # with circles that intersect at one point
     arc5 = Arc(Point(4, 0), 0, 4, 100)
     arc6 = Arc(Point(8, 4), -90, 2, -30)
     self.assertEqual(arc5._find_arc_intersection(arc6), [Point(8, 4)])
Esempio n. 4
0
 def test_find_arc_intersection_with_arcs_in_the_same_circle(self):
     # intersection between and arc and itself
     arc = Arc(Point(4, 3), 67, 2, 99)
     self.assertEqual(arc._find_arc_intersection(arc), [arc])
     # with no intersection
     arc1 = Arc(Point(1, 0), 90, 1, 90)
     arc2 = Arc(Point(-1, 0), 270, 1, 90)
     self.assertEqual(arc1._find_arc_intersection(arc2), [])
     # with one point intersection
     arc1 = Arc(Point(1, 0), 90, 1, 90)
     arc2 = Arc(Point(0, 1), 180, 1, 90)
     self.assertAlmostEqual(arc1._find_arc_intersection(arc2),
                            [Point(0, 1)])
     self.assertAlmostEqual(arc2._find_arc_intersection(arc1),
                            [Point(0, 1)])
     # with two points intersection
     arc1 = Arc(Point(1, 0), 90, 1, 180)
     arc2 = Arc(Point(1, 0), -90, 1, -180)
     self.assertAlmostEqual(arc1._find_arc_intersection(arc2),
                            [Point(-1, 0), Point(1, 0)])
     self.assertAlmostEqual(arc2._find_arc_intersection(arc1),
                            [Point(1, 0), Point(-1, 0)])
     # with one arc intersection
     arc1 = Arc(Point(0, -1), 0, 1, 180)
     arc2 = Arc(Point(1, 0), 90, 1, 180)
     expected_arc = Arc(Point(1, 0), 90, 1, 90)
     self.assertEqual(arc1._find_arc_intersection(arc2), [expected_arc])
     self.assertEqual(arc2._find_arc_intersection(arc1), [expected_arc])
     # with one arc contained in the other
     arc1 = Arc(Point(2, 4), -90, 2, 270)
     arc2 = Arc(Point(6, 4), 270, 2, -90)
     self.assertAlmostEqual(arc1._find_arc_intersection(arc2),
                            [Arc(Point(4, 2), 0, 2, 90)])
     self.assertAlmostEqual(arc2._find_arc_intersection(arc1),
                            [Arc(Point(4, 2), 0, 2, 90)])
     # with same start point and different end points
     arc1 = Arc(Point(0, -1), 0, 1, 90)
     arc2 = Arc(Point(0, -1), 0, 1, 180)
     self.assertAlmostEqual(arc1._find_arc_intersection(arc2), [arc1])
     self.assertAlmostEqual(arc2._find_arc_intersection(arc1), [arc1])
     # with the same end point and different start points
     arc1 = Arc(Point(1, 0), 90, 1, 180)
     arc2 = Arc(Point(0, 1), 180, 1, 90)
     self.assertAlmostEqual(arc1._find_arc_intersection(arc2), [arc2])
     self.assertAlmostEqual(arc2._find_arc_intersection(arc1), [arc2])
     # with two arcs intersection
     arc1 = Arc(Point(-1, 0), 270, 1, 270)
     arc2 = Arc(Point(1, 0), 90, 1, 270)
     expected_intersection = [
         Arc(Point(1, 0), 90, 1, 90),
         Arc(Point(-1, 0), 270, 1, 90)
     ]
     self.assertAlmostEqual(arc1._find_arc_intersection(arc2),
                            expected_intersection)
     # with and arc in clockwise direction
     arc1 = Arc(Point(0, 1), 0, 1, -270)
     arc2 = Arc(Point(1, 0), 90, 1, 270)
     expected_intersection = [
         Arc(Point(1, 0), 90, 1, 90),
         Arc(Point(-1, 0), 270, 1, 90)
     ]
     self.assertAlmostEqual(arc1._find_arc_intersection(arc2),
                            expected_intersection)
Esempio n. 5
0
 def test_find_arc_intersection_with_circles_that_intersect_but_no_arc_intersection(
         self):
     arc1 = Arc(Point(5, 0), 90, 5, 10)
     arc2 = Arc(Point(0, 3), 0, 5, 10)
     self.assertEqual(arc1._find_arc_intersection(arc2), [])