示例#1
0
 def __init__(self, children=[], **kwargs):
     CadInterface.__init__(self, **kwargs)
     self._lines = [
         MepCurve2d.from_viper(**x) for x in children
         if x.get('geomType', None) is not None
     ]
     Polygon.__init__(self, [x.points[0] for x in self._lines])
示例#2
0
 def __init__(self, args, env=None, name=None):
     if isinstance(args, np.ndarray):
         args = args.tolist()
     Polygon.__init__(self, args)
     self._name = name
     self._parent = env
     self._s = 0.25
示例#3
0
  def set(self, center, northern_most_unit_vector_direction, side_length, parent, depth=None):
    # The Hexagon class is a representation of a 2D planar hexagon,
    #  represented in Cartesian coordinates of the center and all vertices.
    #
    # center := an absolute point, as a 2D numpy column vector, representing
    #  the center of hexagon in a Cartesian coordinate system.
    #
    # northern_most_vertex_direction := a free unit vector, as a 2D numpy
    #  column vector, indicating the direction of the northern-most vertex.
    #
    # side_length := a scalar representing the length of any side of the
    #  resulting hexagon.
    self.initialized = True
    if depth is not None:
      self.depth = depth
    self.center = center.copy()
    self.north_unit_dir = northern_most_unit_vector_direction.copy()
    self.side_length = side_length
    scaled_north_dir = side_length * northern_most_unit_vector_direction
    north = scaled_north_dir + self.center

    # From the center point and the north vertex, we can compute the other
    #  vertices of the hexagon. Each vertex, relative to the center, is
    #  simply the previous vector rotated by 60 degrees (pi/3 radians).
    # Perform this rotation five times to calculate the direction of all
    #  six hexagon vertices.
    self.vertex_directions = [scaled_north_dir]
    self.vertices = [north]
    for i in range(5):
      prev_direction = self.vertex_directions[-1]
      rotated_direction = rotate_60 * prev_direction
      self.vertex_directions.append(rotated_direction)

      # Calculate Cartesian coordinates of vertex.
      vertex = rotated_direction + self.center
      self.vertices.append(vertex)

    self.north_dir,\
    self.northeast_dir,\
    self.southeast_dir,\
    self.south_dir,\
    self.southwest_dir,\
    self.northwest_dir = self.vertex_directions

    self.north_vertex,\
    self.northeast_vertex,\
    self.southeast_vertex,\
    self.south_vertex,\
    self.southwest_vertex,\
    self.northwest_vertex = self.vertices
    Polygon.__init__(self, self.vertices)

    # The following member variables correspond to points to neighboring
    #  hexagons related to the topological relationship between this hexagon
    #  and neighboring hexagons.
    self.neighboring_hexagons = [None for i in range(6)]
    self.internal_hexagons = [None for i in range(7)]
    self.parent = parent
示例#4
0
  def __init__(self, x, y, width, height, rotation, visible):
    self.x = x
    self.y = y
    self.width = width
    self.height = height
    self.rotation = rotation
    self.visible = visible

    w2 = width / 2.
    h2 = height / 2.
    l = []
    for k in range(4):
      l.append(rotate((mx[k] * w2, my[k] * h2), rotation))

    l = [(a[0] + x, a[1] + y) for a in l]
    Polygon.__init__(self, l)
示例#5
0
    def __init__(self, x, y, width, height, rotation, visible):
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.rotation = rotation
        self.visible = visible

        w2 = width / 2.
        h2 = height / 2.
        l = []
        for k in range(4):
            l.append(rotate((mx[k] * w2, my[k] * h2), rotation))

        l = [(a[0] + x, a[1] + y) for a in l]
        Polygon.__init__(self, l)
示例#6
0
 def __init__(self, poly_points):
     Polygon.__init__(self, poly_points)
示例#7
0
 def __init__(self, poly_points):
     Polygon.__init__(self, poly_points)
示例#8
0
 def __init__(self, path, level=None, id=None):
     self._path = path
     Polygon.__init__(self, path, None)
     self.lvl = level
     self.z = self.lvl
     self.id = id
 def __init__(self, tid, points):
     Polygon.__init__(self, points)
     self.tid = tid
示例#10
0
 def __init__(self, minx, miny, maxx, maxy):
     minx = float(minx)
     miny = float(miny)
     maxx = float(maxx)
     maxy = float(maxy)
     Polygon.__init__(self, [(minx, miny), (minx, maxy), (maxx, maxy), (maxx, miny)])