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)
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)
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)
def test_different_dimensions(self): with self.assertRaises(ValueError): VectorLine(Vector(2, 7, 4), Vector(5, 8))
def test_creation(self): self.assertIsInstance(Vector(1, 2, 3, 4), Vector)
def test_creation(self): self.assertIsInstance(Vector(4, 2, 9), Point3D)
def test_creation(self): self.assertIsInstance(Vector(1, 2), Point2D)
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))
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))