Пример #1
0
 def test_intercept_lines_2d(self):
     u = VectorLine(Vector(0, 3), Vector(2, -1))
     v = VectorLine(Vector(0, 0), Vector(1, -1))
     intercept = u.intersect(v)
     self.assertIsInstance(intercept, PointIntersection)
     self.assertEqual(intercept.point, Vector(3, -3))
     self.assertEqual(intercept.point, v.intersect(u).point)
Пример #2
0
 def test_creation(self):
     self.assertIsInstance(
         VectorLine(Vector(2, 7, 4, 6), Vector(5, 8, 2, 1)), VectorLine)
     self.assertIsInstance(VectorLine(Vector(2, 7, 4), Vector(5, 8, 2)),
                           VectorLine3D)
     self.assertIsInstance(VectorLine(Vector(2, 7), Vector(5, 8)),
                           VectorLine2D)
Пример #3
0
 def test_intercept_point_on_line(self):
     u = VectorLine(Vector(1, 1), Vector(2, 0))
     v = Vector(3, -1)
     intercept = u.intersect(v)
     self.assertIsInstance(intercept, PointIntersection)
     self.assertEqual(intercept.point, Vector(3, -1))
     self.assertEqual(intercept.point, v.intersect(u).point)
Пример #4
0
 def test_different_dimensions(self):
     with self.assertRaises(ValueError):
         VectorLine(Vector(2, 7, 4), Vector(5, 8))
Пример #5
0
 def test_creation(self):
     self.assertIsInstance(Vector(1, 2, 3, 4), Vector)
Пример #6
0
 def test_creation(self):
     self.assertIsInstance(Vector(4, 2, 9), Point3D)
Пример #7
0
 def test_creation(self):
     self.assertIsInstance(Vector(1, 2), Point2D)
Пример #8
0
 def test_intercept_parallel_line_2d(self):
     u = VectorLine(Vector(1, 1), Vector(2, 0))
     v = VectorLine(Vector(0, 0), Vector(2, -2))
     self.assertIsNone(u.intersect(v))
     self.assertIsNone(v.intersect(u))
Пример #9
0
 def test_intercept_point_outside_line(self):
     u = VectorLine(Vector(0, 0), Vector(2, -2))
     v = Vector(3, -1)
     self.assertIsNone(u.intersect(v))
     self.assertIsNone(v.intersect(u))