def generate_points(min, max, total):
    points = [[random.choice(range(min,max)), random.choice(range(min,max))] for i in range(total)]
    return points

if __name__ == '__main__':
    min_val = -100000
    max_val = 100000
    total_points = 500

    start = time.time()
    points = generate_points(min_val, max_val, total_points)
    end = time.time()
    print("generated data in %g seconds" % (end - start))

    '''
    start_time = time.time()
    BF_hull = bf.brute_force(points)
    end_time = time.time()
    print("BruteForce took: %g seconds" % (end_time - start_time))
    '''
    start_time = time.time()
    q_hull = qh.quick_hull(points)
    end_time = time.time()
    print("QuickHull took: %g seconds" % (end_time - start_time))

    plot(points, q_hull, min_val, max_val)



Example #2
0
if points_mode == "random":
    cant = 1000
    xlim = [-1000, 1000]
    ylim = [-1000, 1000]
    points = random_points(cant, xlim, ylim)

if points_mode == "circle":
    points = []
    for dd in range(0, 3600, 10):
        d = dd/10.
        x = 100*cos(radians(d))
        y = 100*sin(radians(d))
        points.append(Point(x, y))

# vectors tiene las aristas del convex hull
# desordenadas (pero apuntando en la direccion
# correcta). Se puede hacer un algoritmo
# n*log(n) para pasar de esa lista de vectores
# a la lista de los puntos ordenada.
ini = time()
vectors = quick_hull(points)
fin = time()

print("Time: %f seconds." % (fin - ini))

draw_points(points)
for v in vectors:
    flecha(v[0], v[1])

plt.show()