当前位置: 首页>>代码示例>>Python>>正文


Python polygon.Polygon类代码示例

本文整理汇总了Python中polygon.Polygon的典型用法代码示例。如果您正苦于以下问题:Python Polygon类的具体用法?Python Polygon怎么用?Python Polygon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Polygon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_should_retrieve_false_to_a_point_that_is_not_inside_a_polygon

 def test_should_retrieve_false_to_a_point_that_is_not_inside_a_polygon(self):
     A = [3, 6]; B = [3, 11]; C = [6, 11]; D = [6, 9]; E = [5, 9]; F = [5, 6]
     polygon = Polygon([A, B, C, D, E, F])
     test_point = [4, 5]
     assert_false(polygon.belongs_to_polygon(test_point))
     test_point = [6, 7]
     assert_false(polygon.belongs_to_polygon(test_point))
开发者ID:flaviamissi,项目名称:Point-Inside-Polygon,代码行数:7,代码来源:test_point_inside_polygon.py

示例2: __init__

 def __init__(self, position = (0, 0), node_list = []):
     Polygon.__init__(self, node_list)
     Translatable.__init__(self, position)
     Named.__init__(self)
     self.__connected_objects = []
     self.__pointed_objects = []
     self.add_name('_arrow_')
开发者ID:251,项目名称:shaape,代码行数:7,代码来源:arrow.py

示例3: project

    def project(self, perspective=False):
        p = Polygon()

        for line in self.lines:
            line2d = line.project(perspective)
            p.add_line(line2d)
        return p
开发者ID:drewbanin,项目名称:computer-graphics,代码行数:7,代码来源:face.py

示例4: test_various_points_in_square

    def test_various_points_in_square(self):
        square = Polygon(
            vertex_positions=[
                (1.0, -1.0),
                (1.0, 1.0),
                (-1.0, 1.0),
                (-1.0, -1.0),
            ]
        )
        test_points = []
        for x in range(-3, 4):
            for y in range(-3, 4):
                test_points.append((0.5*x, 0.5*y))

        for point in test_points:
            x, y = point
            if -1 < x < 1 and -1 < y < 1:
                # Point is inside.
                self.assertEqual(square.winding_number(point), 1)
            elif x < -1 or x > 1 or y < -1 or y > 1:
                # Point outside.
                self.assertEqual(square.winding_number(point), 0)
            else:
                with self.assertRaises(ValueError):
                    square.winding_number(point)
开发者ID:mdickinson,项目名称:polyhedron,代码行数:25,代码来源:test_polygon.py

示例5: generate_new_poly

 def generate_new_poly(self, ev):
     points = get_random_polygon()
     self.set_points(points)
     poly = Polygon()
     poly.set_points(points)
     self.canvas.delete("all")
     self.draw_polygon_points(poly)
     self.set_result(0)
开发者ID:vrublevskiyvitaliy,项目名称:Coursework,代码行数:8,代码来源:gui.py

示例6: __init__

 def __init__(self, position, rotation, color):
     p1 = Point(0,-4)
     p2 = Point(0,4)
     p3 = Point(20,0)
     self.outline = [p3, p1, p2] 
     self.position = position
     self.rotation = rotation
     self.color = color
     Polygon.__init__(self, self.outline, self.position, self.rotation, self.color)
开发者ID:adirksen,项目名称:Python,代码行数:9,代码来源:Ship.py

示例7: make_square

 def make_square( self, top_left, bottom_right, z ):
     colour = 255 - z % 100
     a, b = top_left
     c, d = bottom_right
     square = Polygon( ( colour, colour, colour ) ).add( Point( a, b, z ) ) \
         .add( Point( b, c, z ) ).add( Point( c, d, z ) ) \
         .add( Point( d, a, z ) )
     square.set_width( 1 )
     return square
开发者ID:eZanmoto,项目名称:Modeller-3D,代码行数:9,代码来源:modeller3d.py

示例8: create_linked_list

def create_linked_list(filename='input.txt'):
    
    points = read_from_file(filename)

    poly = Polygon()
    poly.set_points(points)

    points = poly.get_linked_list()
        
    return points[0], len(points)
开发者ID:vrublevskiyvitaliy,项目名称:Coursework,代码行数:10,代码来源:ioclass.py

示例9: test_clockwise_square

 def test_clockwise_square(self):
     square = Polygon(
         vertex_positions=[
             (1.0, -1.0),
             (1.0, 1.0),
             (-1.0, 1.0),
             (-1.0, -1.0),
         ][::-1]
     )
     origin = (0.0, 0.0)
     self.assertEqual(square.winding_number(origin), -1)
     self.assertEqual(square.area(), -4.0)
开发者ID:mdickinson,项目名称:polyhedron,代码行数:12,代码来源:test_polygon.py

示例10: test_double_square

 def test_double_square(self):
     square = Polygon(
         vertex_positions=[
             (1.0, -1.0),
             (1.0, 1.0),
             (-1.0, 1.0),
             (-1.0, -1.0),
         ] * 2
     )
     origin = (0.0, 0.0)
     self.assertEqual(square.winding_number(origin), 2)
     self.assertEqual(square.area(), 8.0)
开发者ID:mdickinson,项目名称:polyhedron,代码行数:12,代码来源:test_polygon.py

示例11: test_simple_square

 def test_simple_square(self):
     square = Polygon(
         vertex_positions=[
             (1.0, -1.0),
             (1.0, 1.0),
             (-1.0, 1.0),
             (-1.0, -1.0),
         ]
     )
     origin = (0.0, 0.0)
     self.assertEqual(square.winding_number(origin), 1)
     self.assertEqual(square.area(), 4.0)
开发者ID:mdickinson,项目名称:polyhedron,代码行数:12,代码来源:test_polygon.py

示例12: create_random

 def create_random(self, n):
   """ Create n polygons with random vertices. The dimensions of each
   picture should be specified with max_x and may_y.
   
   """
   self.polygons = []
   for i in xrange(0, n):
     p = Polygon()
     # 3 to 5 vertices
     Polygon.create_random(p, random.randint(3,5))
     self.polygons.append(p)
   return self
开发者ID:,项目名称:,代码行数:12,代码来源:

示例13: __init__

	def __init__(self):
		shape = [Point(24, 0), Point(-12, -12), Point(0, 0), Point(-12, 12)]
		position = Point(config.SCREEN_X/2, config.SCREEN_Y/2)
		self.rotation = config.SHIP_INITIAL_DIRECTION
		color = config.SHIP_COLOR
		Polygon.__init__(self, shape, position, self.rotation, color)
		self.accelerate = (0, 0)
		self.stop = Point(0, 0)
		pygame.mixer.init()
		self.fire_sfx = pygame.mixer.Sound("laser.wav")
		self.count = 5
		self.shield_health = 100
		self.nuke_count = 1
开发者ID:majormoses,项目名称:asteroids,代码行数:13,代码来源:ship.py

示例14: __init__

 def __init__(self, position, rotation, color, rotation_speed, motion):
     self.outline = []
     for angle in range(0, 360, 360/config.ROCK_POLYGON_SIZE):
         radius = random.uniform(config.ROCK_MIN_RADIUS, config.ROCK_MAX_RADIUS)
         angle_rad = math.radians(angle)
         (x,y) = math.cos(angle_rad) * radius, math.sin(angle_rad) * radius
         p = Point(x,y)
         self.outline.append(p)
     self.position = position
     self.rotation = rotation
     self.color = color
     self.rotation_speed = rotation_speed
     self.motion = motion
     Polygon.__init__(self, self.outline, self.position, self.rotation, self.color)
     self.accelerate(self.motion)
开发者ID:rrydman,项目名称:Asteroids,代码行数:15,代码来源:Rock.py

示例15: test_numpy_compatibility

 def test_numpy_compatibility(self):
     square = Polygon(
         vertex_positions=numpy.array(
             [
                 [1.0, -1.0],
                 [1.0, 1.0],
                 [-1.0, 1.0],
                 [-1.0, -1.0],
             ],
             dtype=numpy.float64,
         )
     )
     origin = numpy.array([0.0, 0.0], dtype=numpy.float64)
     self.assertEqual(square.winding_number(origin), 1)
     self.assertEqual(square.area(), 4.0)
开发者ID:mdickinson,项目名称:polyhedron,代码行数:15,代码来源:test_polygon.py


注:本文中的polygon.Polygon类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。