@spela.kranjec21 wrote:
Hi, I am new with python and I am still learning so my problem might be very trivial but I just cannot get the right solution for this problem.
So, I have randomly generated points inside a square. Each point has a radius. But the problem with generated points is that they are overlapping each other. How can I resolve this?
Thank you for your help in advance.roof with holes.gh (22.9 KB)
import rhinoscriptsyntax as rs
from math import sin, cos, pi
import random#square
a = 50
b = 50V1 = 0, 0, 0
V2 = 0, b, 0
V3 = a, b, 0
V4 = a, 0, 0
vogali = [V1,V2,V3,V4]#draw edges
edges =
for i in range(4):
edges.append(rs.AddLine(vogali[i-1],vogali[i],))#randomly generated points
points_d =
points_u =
x = 0
y = 0for i in range(n_points):
delta_x = 0.025 * a
delta_y = 0.025 * b
radius = min(delta_x, delta_y)x = random.random() * a y = random.random() * b z = 0 #check for each point if it ovelapps the other if x != y and y * delta_y != x * delta_x : points_u.append(rs.AddPoint(x,y,z)) points_d.append(rs.AddPoint(x,y,max(a,b)))
Posts: 7
Participants: 2