Ejemplo n.º 1
0
        # best tour
        uberplot.plot_segments(ax, utils.tour(traj), **theme["tour"])

if not ask_for.noplot_penrose:
    LOGN("\ttiling", len(penrose_segments), "segments")
    uberplot.plot_segments(ax, penrose_segments, **theme["penrose"])

if not ask_for.noplot_triangulation:
    LOGN("\ttriangulation", len(triangulation_edges), "edges")
    uberplot.plot_segments(ax, triangulation_edges, **theme["triangulation"])

if not ask_for.noplot_voronoi:
    LOGN("\tVoronoï", len(voronoi_edges), "edges")
    # uberplot.plot_segments( ax, voronoi_tri_edges, edgecolor="red", alpha=1, linewidth=1 )
    # uberplot.scatter_points( ax, voronoi_tri_centers, edgecolor="red", facecolor="white", s=200, alpha=1, zorder=10 )
    uberplot.plot_segments(ax, voronoi_edges, **theme["voronoi_edges"])
    uberplot.scatter_points(ax, voronoi_centers, **theme["voronoi_nodes"])

ax.set_aspect('equal')

# transparent background in SVG
fig.patch.set_visible(False)
ax.axis('off')
plot.savefig("ubergeekism_d%i.svg" % depth, dpi=dpi)

fig.patch.set_visible(True)
fig.patch.set_facecolor('white')
plot.savefig("ubergeekism_d%i.png" % depth, dpi=dpi)

plot.show()
Ejemplo n.º 2
0
    for s0 in segments:
        for s1 in segments:
            if s0 != s1:
                s = segment_intersection( s0, s1 )
                if s is not None:
                    seg_inter.append(s)
                l = line_intersection( s0, s1 )
                if l is not None:
                    line_inter.append(l)


    fig = plot.figure()

    ax = fig.add_subplot(121)
    uberplot.plot_segments( ax, segments, linewidth=0.5, edgecolor = "blue" )
    uberplot.scatter_points( ax, points,     edgecolor="blue", facecolor="blue",  s=120, alpha=1, linewidth=1 )
    uberplot.scatter_points( ax, line_inter, edgecolor="none", facecolor="green", s=60,  alpha=0.5 )
    uberplot.scatter_points( ax, seg_inter,  edgecolor="none", facecolor="red",   s=60,  alpha=0.5 )
    ax.set_aspect('equal')


    # collinear test demo
    if len(sys.argv) > 1:
        scale = 100
        nb = int(sys.argv[1])
        triangles = []
        for t in range(nb):
            triangles.append( [ [scale*random.random(),scale*random.random()] for i in range(3)] )
            # forced collinear
            t = [ [scale*random.random(),scale*random.random()] for i in range(2)]
            triangles.append( [t[0],t[1],t[0]] )
Ejemplo n.º 3
0
            if s0 != s1:
                s = segment_intersection(s0, s1)
                if s is not None:
                    seg_inter.append(s)
                l = line_intersection(s0, s1)
                if l is not None:
                    line_inter.append(l)

    fig = plot.figure()

    ax = fig.add_subplot(121)
    uberplot.plot_segments(ax, segments, linewidth=0.5, edgecolor="blue")
    uberplot.scatter_points(ax,
                            points,
                            edgecolor="blue",
                            facecolor="blue",
                            s=120,
                            alpha=1,
                            linewidth=1)
    uberplot.scatter_points(ax,
                            line_inter,
                            edgecolor="none",
                            facecolor="green",
                            s=60,
                            alpha=0.5)
    uberplot.scatter_points(ax,
                            seg_inter,
                            edgecolor="none",
                            facecolor="red",
                            s=60,
                            alpha=0.5)
Ejemplo n.º 4
0
    n=200
    points = [ ( round(random.uniform(-n,n),2),round(random.uniform(-n,n),2) ) for i in range(n) ]

    quad = QuadTree( points )
    # print(quad)
    # sys.stderr.write( "%i points in the quadtree / %i points\n" % (len(quad), len(points)) )


    fig = plot.figure()

    ax = fig.add_subplot(111)
    ax.set_aspect('equal')

    # Plot the whole quad tree and its points.
    # Iterating over the quadtree will generate points, thus list(quad) is equivalent to quad.points()
    uberplot.scatter_points( ax, list(quad), facecolor="green", edgecolor="None")

    for q in quad.quadrants:
        edges = list( utils.tour(as_rect(q)) )
        uberplot.plot_segments( ax, edges, edgecolor = "blue", alpha = 0.1, linewidth = 2 )

    # Plot a random query on the quad tree.
    # Remember a quadrant is ( (orig_y,orig_y), width )
    minp = ( round(random.uniform(-n,n),2), round(random.uniform(-n,n),2) )
    rand_quad = ( minp, round(random.uniform(0,n),2) )
    # Asking for a quadrant will query the quad tree and return the corresponding points.
    uberplot.scatter_points( ax, quad[rand_quad], facecolor="None", edgecolor="red", alpha=0.5, linewidth = 2 )
    edges = list( utils.tour(as_rect(rand_quad)) )
    uberplot.plot_segments( ax, edges, edgecolor = "red", alpha = 0.5, linewidth = 2 )

    plot.show()
Ejemplo n.º 5
0
        uberplot.plot_segments( ax, utils.tour(traj), **theme["tour"])

if not ask_for.noplot_penrose:
    LOGN( "\ttiling",len(penrose_segments),"segments" )
    uberplot.plot_segments( ax, penrose_segments, **theme["penrose"])

if not ask_for.noplot_triangulation:
    LOGN( "\ttriangulation",len(triangulation_edges),"edges" )
    uberplot.plot_segments( ax, triangulation_edges, **theme["triangulation"])

if not ask_for.noplot_voronoi:
    LOGN( "\tVoronoï",len(voronoi_edges),"edges")
    # uberplot.plot_segments( ax, voronoi_tri_edges, edgecolor="red", alpha=1, linewidth=1 )
    # uberplot.scatter_points( ax, voronoi_tri_centers, edgecolor="red", facecolor="white", s=200, alpha=1, zorder=10 )
    uberplot.plot_segments(  ax, voronoi_edges,   **theme["voronoi_edges"] )
    uberplot.scatter_points( ax, voronoi_centers, **theme["voronoi_nodes"] )

ax.set_aspect('equal')


# transparent background in SVG
fig.patch.set_visible(False)
ax.axis('off')
plot.savefig("ubergeekism_d%i.svg" % depth, dpi=dpi)

fig.patch.set_visible(True)
fig.patch.set_facecolor('white')
plot.savefig("ubergeekism_d%i.png" % depth, dpi=dpi)

plot.show()
Ejemplo n.º 6
0
    points = [(round(random.uniform(-n, n), 2), round(random.uniform(-n, n),
                                                      2)) for i in range(n)]

    quad = QuadTree(points)
    # print(quad)
    # sys.stderr.write( "%i points in the quadtree / %i points\n" % (len(quad), len(points)) )

    fig = plot.figure()

    ax = fig.add_subplot(111)
    ax.set_aspect('equal')

    # Plot the whole quad tree and its points.
    # Iterating over the quadtree will generate points, thus list(quad) is equivalent to quad.points()
    uberplot.scatter_points(ax,
                            list(quad),
                            facecolor="green",
                            edgecolor="None")

    for q in quad.quadrants:
        edges = list(utils.tour(as_rect(q)))
        uberplot.plot_segments(ax,
                               edges,
                               edgecolor="blue",
                               alpha=0.1,
                               linewidth=2)

    # Plot a random query on the quad tree.
    # Remember a quadrant is ( (orig_y,orig_y), width )
    minp = (round(random.uniform(-n, n), 2), round(random.uniform(-n, n), 2))
    rand_quad = (minp, round(random.uniform(0, n), 2))
    # Asking for a quadrant will query the quad tree and return the corresponding points.