예제 #1
0
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))
예제 #2
0


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