Example #1
0
    def __init__(self,
                 generations,
                 fmax,
                 linewidth=1,
                 xaxis_div=20,
                 yaxis_div=10,
                 fontsize=10,
                 pointsize=0.1):
        Plotter.__init__(self, tight=True)

        self.generations = generations
        self.fmax = fmax
        self.linewidth = linewidth
        self.xaxis_div = xaxis_div
        self.yaxis_div = yaxis_div
        self.fontsize = fontsize
        self.pointsize = pointsize

        self.mean = []
        self.max = []
        self.min = []

        self.draw_axes()
Example #2
0
        matrix : list of list
            The transformation matrix.

        Returns
        -------
        Polygon
            The transformed copy.

        """
        polygon = self.copy()
        polygon.transform(matrix)
        return polygon


# ==============================================================================
# Main
# ==============================================================================

if __name__ == '__main__':

    from compas.plotters import Plotter

    polygon = Polygon([[1, 1, 0], [0, 1, 0], [0, 0, 0], [1, 0, 0]])

    for point in polygon.points:
        print(point[0:2])

    plotter = Plotter(figsize=(10, 7))
    plotter.draw_polygons([{'points': polygon.points}])
    plotter.show()
Example #3
0
            exclude.add(nnbr[1])
        if distance_sort:
            return sorted(nnbrs, key=lambda nnbr: nnbr[2])
        return nnbrs


# ==============================================================================
# Main
# ==============================================================================

if __name__ == '__main__':

    from compas.geometry import pointcloud_xy
    from compas.plotters import Plotter

    plotter = Plotter()

    cloud = pointcloud_xy(999, (-500, 500))
    point = cloud[0]

    tree = KDTree(cloud)

    n = 50
    nnbrs = []
    exclude = set()

    for i in range(n):
        nnbr = tree.nearest_neighbor(point, exclude)
        nnbrs.append(nnbr)
        exclude.add(nnbr[1])
Example #4
0
from compas.geometry import Line
from compas.plotters import Plotter

# create a line
line = Line([0, 0, 0], [1, 1, 1])
# compute a line midpoint
mid_pt = line.midpoint
print(mid_pt)

# create a plotter with figsize=(10, 6)
plotter = Plotter(figsize=(10, 6))

# create lines to draw
lines = [{'start': line.start, 'end': line.end, 'width': 1.0}]
# create start points to draw
points = [{
    'pos': line.start,
    'radius': 0.05,
    'facecolor': '#ffffff',
    'text': 'start_point: {}'.format(line.start)
}]

# create mid point to draw
points.append({'pos': mid_pt, 'radius': 0.05, 'facecolor': '#ff0000'})

# draw lines and points
plotter.draw_lines(lines)
plotter.draw_points(points)

# plot
plotter.show()
Example #5
0
        return n
    lvec = length_vector_xy(n)
    return n[0] / lvec, n[1] / lvec, n[2] / lvec


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    from compas.geometry import area_polygon
    from compas.geometry import centroid_points
    from compas.plotters import Plotter

    plotter = Plotter(figsize=(10, 7))

    points = [[0, 0, 0], [1.0, 0, 0], [1.0, 1.0, 0], [0.5, 0.0, 0],
              [0, 1.0, 0]]
    polygon = points[::-1]

    print(polygon)
    print(area_polygon(polygon))

    n = normal_polygon(polygon, unitized=False)
    print(n)

    if n[2] > 0:
        color = '#ff0000'
    else:
        color = '#0000ff'