Beispiel #1
0
    def test_segments_in_rec(self):
        r = Rectangle((0,0), (19,16))
        s = LineSegment(np.array([4,4]), np.array([11,9]))
        self.assertTrue(r.overlaps(s))
        self.assertTrue(s.overlaps(r))

        s2 = LineSegment(np.array([-2,6]), np.array([11,9]))
        self.assertTrue(r.overlaps(s2))
        self.assertTrue(s2.overlaps(r))
Beispiel #2
0
    def test_segments(self):
        l1 = LineSegment(np.array([0,0]), np.array([2,2]))
        l2 = LineSegment(np.array([0,0]), np.array([3,-2]))
        self.assertTrue(l1.overlaps(l2))
        self.assertTrue(l2.overlaps(l1))

        l2 = LineSegment(np.array([-1,-1]), np.array([3,3]))
        self.assertTrue(l1.overlaps(l2))
        self.assertTrue(l2.overlaps(l1))

        l2 = LineSegment(np.array([-1,-2]), np.array([4,3]))
        self.assertFalse(l1.overlaps(l2))
        self.assertFalse(l2.overlaps(l1))

        l2 = LineSegment(np.array([3,-1]), np.array([-1,3]))
        self.assertTrue(l1.overlaps(l2))
        self.assertTrue(l2.overlaps(l1))