def test_general_intersection(self): "test non intersecting segments" tan1 = Tangent(Vec2D(1, 0), None, None, Vec2D(2, 0), None, None) tan2 = Tangent(Vec2D(0, -2), None, None, Vec2D(0, -1), None, None) self.assertFalse(tan1.intersect(tan2)) self.assertFalse(tan2.intersect(tan1))
def test_colinear_nonoverlapping(self): "test that colinear nonoverlapping doesn't count as intersection" tan1 = Tangent(Vec2D(1, 0), None, None, Vec2D(2, 0), None, None) tan2 = Tangent(Vec2D(-2, 0), None, None, Vec2D(0, 0), None, None) self.assertFalse(tan1.intersect(tan2)) self.assertFalse(tan2.intersect(tan1))
def test_parallel_intersection(self): "test that parallel segments don't intersect" tan1 = Tangent(Vec2D(1, 0), None, None, Vec2D(2, 0), None, None) tan2 = Tangent(Vec2D(1, 1), None, None, Vec2D(2, 1), None, None) self.assertFalse(tan1.intersect(tan2)) self.assertFalse(tan2.intersect(tan1))
def test_simple_intersection(self): "test simple 1 point intersection" tan1 = Tangent(Vec2D(-1, 0), None, None, Vec2D(1, 0), None, None) tan2 = Tangent(Vec2D(0, -1), None, None, Vec2D(0, 1), None, None) self.assertTrue(tan1.intersect(tan2)) self.assertTrue(tan2.intersect(tan1))
def test_overlapping_intersection(self): "test that overlapping counts as intersection" tan1 = Tangent(Vec2D(-1, 0), None, None, Vec2D(1, 0), None, None) tan2 = Tangent(Vec2D(-2, 0), None, None, Vec2D(0, 0), None, None) self.assertTrue(tan1.intersect(tan2)) self.assertTrue(tan2.intersect(tan1))