Exemple #1
0
 def test_zoom_with_enclosure(self):
     """Zoom test with off center circle and difference enclosure"""
     input_ = circ._Circle(1.0, 0.0, 1.0)
     enclosure = circ._Circle(0.0, 0.0, 2.0)
     target = circ._Circle(0.0, 0.0, 1.0)
     actual = circ.scale(input_, target, enclosure)
     expected = circ._Circle(0.5, 0.0, 0.5)
     self.assertEqual(expected, actual)
Exemple #2
0
    def test_tiny_circle_contained_inside_other(self):
        """Testing for numerical problems with floating point math

        When the inner circle is right on the outer circle, we need to handle
        possible DomainError raised by the sqrt of negative number.

        """
        c1 = circ._Circle(x=-0.005574001032652584,
                          y=0.10484176298731643,
                          r=0.05662982038967889)
        c2 = circ._Circle(x=0.029345054623395653,
                          y=0.06025929883988402,
                          r=2.220446049250313e-15)
        self.assertEqual(circ.get_intersection(c1, c2), (None, None))
Exemple #3
0
    def test_small_circle_that_does_intersect(self):
        """Testing for small circle that can be computed

        At the same time, the condition should not throw out configuration
        that can be computed.

        """
        c1 = circ._Circle(x=-0.005574001032652584,
                          y=0.10484176298731643,
                          r=0.05662982038967889)
        c2 = circ._Circle(x=0.029345054623395653,
                          y=0.06025929883988402,
                          r=1.0e-09)
        self.assertEqual(
            circ.get_intersection(c1, c2),
            (
                (0.029345053725419824, 0.06025929813654767),
                (0.029345055521371476, 0.06025929954322038),
            ),
        )
Exemple #4
0
 def test_simple_zoom_and_translation(self):
     """Pan and zoom test with off center circle equal to enclosure."""
     input_ = circ._Circle(0.5, 0.5, 0.5)
     target = circ._Circle(-0.5, 0, 1.0)
     actual = circ.scale(input_, target, input_)
     self.assertEqual(target, actual)
Exemple #5
0
 def test_simple_zoom_off_center(self):
     """Zoom test with off center circle equal to enclosure."""
     input_ = circ._Circle(0.5, 0.5, 0.5)
     target = circ._Circle(0.5, 0.5, 1.0)
     actual = circ.scale(input_, target, input_)
     self.assertEqual(target, actual)
Exemple #6
0
 def test_simple_zoom(self):
     """Trivial zoom test when the enclosure is the same as the circle."""
     input_ = circ._Circle(0, 0, 0.5)
     target = circ._Circle(0, 0, 1.0)
     actual = circ.scale(input_, target, input_)
     self.assertEqual(target, actual)