Beispiel #1
0
 def test_line_intersect_order_independent(self):
     a1 = (0.0, 0.0)
     a2 = (2.0, 0.0)
     b1 = (0.5, -0.5)
     b2 = (0.5, 0.5)
     hit1 = line_intersect(a1, a2, b1, b2)
     hit2 = line_intersect(b1, b2, a1, a2)
     self.assertEqual(hit1[0], hit2[0],
                      'order of line segment points should not matter')
     self.assertEqual(hit1[1], hit2[1],
                      'order of line segment points should not matter')
Beispiel #2
0
 def test_line_intersect_order_independent(self):
     a1 = (0.0, 0.0)
     a2 = (2.0, 0.0)
     b1 = (0.5, -0.5)
     b2 = (0.5, 0.5)
     hit1 = line_intersect(a1, a2, b1, b2)
     hit2 = line_intersect(b1, b2, a1, a2)
     self.assertEqual(hit1[0], hit2[0],
                      'order of line segment points should not matter')
     self.assertEqual(hit1[1], hit2[1],
                      'order of line segment points should not matter')
Beispiel #3
0
 def test_line_intersect_cross(self):
     ix, iy = line_intersect((0.0, 0.0), (2.0, 0.0), (0.5, -0.5),
                             (0.5, 0.5))
     self.assertAlmostEqual(ix, 0.5, 7,
                            'wrong x-intersection point for cross')
     self.assertAlmostEqual(iy, 0.0, 7,
                            'wrong y-intersection point for cross')
Beispiel #4
0
 def test_line_intersect_miss(self):
     with self.assertRaises(ArithmeticError):
         line_intersect((0, 0), (0, 2), (2, 1), (0, 3))
Beispiel #5
0
 def test_line_intersect_t(self):
     ix, iy = line_intersect((0, 0), (0, 2), (-1, 1), (0, 1))
     self.assertAlmostEqual(ix, 0, 7,
                            'wrong x-intersection point for shared point')
     self.assertAlmostEqual(iy, 1, 7,
                            'wrong y-intersection point for shared point')
Beispiel #6
0
 def test_line_intersect_cross(self):
     ix, iy = line_intersect((0.0, 0.0), (2.0, 0.0), (0.5, -0.5), (0.5, 0.5))
     self.assertAlmostEqual(ix, 0.5, 7,
                            'wrong x-intersection point for cross')
     self.assertAlmostEqual(iy, 0.0, 7,
                            'wrong y-intersection point for cross')
Beispiel #7
0
 def test_line_intersect_miss(self):
     with self.assertRaises(ArithmeticError):
         line_intersect((0, 0), (0, 2), (2, 1), (0, 3))
Beispiel #8
0
 def test_line_intersect_t(self):
     ix, iy = line_intersect((0, 0), (0, 2), (-1, 1), (0, 1))
     self.assertAlmostEqual(ix, 0, 7,
                            'wrong x-intersection point for shared point')
     self.assertAlmostEqual(iy, 1, 7,
                            'wrong y-intersection point for shared point')