示例#1
0
 def test_incircle(self):
     assert sgn(incircle([0, -1], [1, 0], [0, 1], [-0.5, 0])) == 1
     assert sgn(incircle([0, -1], [1, 0], [0, 1], [-1, 0])) == 0
     assert sgn(incircle([0, -1], [1, 0], [0, 1], [-1.5, 0])) == -1
     x = 1e-64
     for i in range(128):
         assert sgn(incircle([0, x], [-x, -x], [x, -x], [0, 0])) == 1
         assert sgn(incircle([0, x], [-x, -x], [x, -x], [0, 2 * x])) == -1
         assert sgn(incircle([0, x], [-x, -x], [x, -x], [0, x])) == 0
         x *= 10
 def test_outside(self):
     """Point outside circle, negative value returned"""
     assert incircle((0,0), (10,0), (0,10), (-100,-100)) == -2200000.0 
 def test_inside(self):
     """Point inside circle, positive value returned"""
     assert incircle((0,0), (10,0), (0,10), (1,1)) == 1800. 
 def test_onboundary(self):
     """Point on boundary of circle, zero"""
     assert incircle((0,0), (10,0), (0,10), (0,10)) == 0.