示例#1
0
 def test_seg_contains(self):
     sb = SegmentedBelt()
     SOL.add(sb.num_segs >= 2)
     SOL.add(sb.segment(0).contains(Point2D(5, 2)))
     SOL.add(sb.segment(1).contains(Point2D(10, 5)))
     SOL.add(sb.segment(0).horizontal())
     SOL.model()
     c1 = SOL.eval(sb.corner(1))
     self.assertEqual(c1, Point2D(10,2))
示例#2
0
    def test_two_seg_belt(self):
        sbelt = SegmentedBelt()
        sbelt.fix_ends(source=(10, 10), sink=(15, 15))
        SOL.add(sbelt.num_segs == 2)
        m = SOL.model()
        self.assertIsNotNone(m)

        s = sbelt.segment(0)
        p1 = s.p1
        p2 = s.p2

        self.assertEqual(p1.eval_as_tuple(), (10,10))
        self.assertTrue(p2.eval_as_tuple() in [(15,10), (10,15)])

        s = sbelt.segment(1)
        p2 = s.p2
        self.assertEqual(p2.eval_as_tuple(), (15,15))
示例#3
0
    def test_one_seg_belt(self):
        sbelt = SegmentedBelt()
        sbelt.fix_ends(source=(10, 10), sink=(15, 10))
        SOL.add(sbelt.num_segs == 1)
        m = SOL.model()
        self.assertIsNotNone(m)

        s = sbelt.segment(0)
        self.assertEqual(s.p1.eval_as_tuple(), (10,10))
        self.assertEqual(s.p2.eval_as_tuple(), (15,10))