class ConvexPolyTestCase(unittest.TestCase): def setUp(self): self.poly = ConvexPoly(((0,0),(4,0),(2,2))) def test_contain(self): self.assertIn((2,1), self.poly) def test_contain(self): self.assertNotIn((-1,4), self.poly) def test_clockwise(self): self.assertFalse(self.poly.is_clockwise()) def test_intersect(self): from geometry import Segment s = Segment((-1,-1), (-3,-3)) self.assertFalse(self.poly.intersect(s)) s = Segment((-1,-1), (5,5)) self.assertTrue(self.poly.intersect(s))
def setUp(self): self.poly = ConvexPoly(((0,0),(4,0),(2,2)))
def __init__(self, p, w): Node.__init__(self) ConvexPoly.__init__(self) self.initFromCarre(Vec(p) * w, w) self.w = w
def __repr__(self): return "Tile(%s, %s)" % (ConvexPoly.__repr__(self), Node.__repr__(self))
import >>> from geometry import ConvexPoly init >>> poly = ConvexPoly(((0,0),(4,0),(2,2))) point dans le poly >>> (2,1) in poly True >>> (-1,4) in poly False isclockwise >>> poly.is_clockwise() False intersection >>> from geometry import Segment >>> poly.intersect(Segment((-1,-1), (-3,-3))) False >>> poly.intersect(Segment((-1,-1), (5,5))) True
def __init__(self, points): ConvexPoly.__init__(self, points) Node.__init__(self)
def __repr__(self): return "Area(%s, %s)" % (ConvexPoly.__repr__(self), Node.__repr__(self))