Closed Durman closed 6 years ago
I stepped through that output when I was coding "Contour 2D", but for the purpose of the node I deleted the separation lines. Probably this lines could be easily exposed to get this "voronoi arc" all the math is already inside the node And it works with weighted radius.
I allready have written something but didn't test it yet.)
def get_arc(start_v, end_v, center_v, resolution, mode='clockwise'):
#return points of arc by two points and center of circle
#resolution determines distanse between points of arc
start_v, end_v = start_v - center_v, end_v - center_v
start_angle = calc_angle(Vector((0,1)), start_v)
#angle between start and end vectors
angle = calc_angle(start_v, end_v)
radius = get_distance(start_v, end_v)
len_arc = get_len_arc(radius, angle)
count = len_arc / resolution
end_angle = start_angle + angle if mode == 'clockwise' else start_angle + angle - TWO_PI
steps_angle = list(np.linspace(start_angle,end_angle,count))
vectors = [Vector((sin(ang),cos(ang))) * radius + center_v for ang in steps_angle]
return vectors
I think about how to keep data now. Just using lists is seemed too confusing. I think I will do two dictionary one for data of vectors and other for data of edges. Dictionary of vectors will keep information about neighbours of current point and something else maybe. Dictionary of edges will keep information about found chords of circles because there is no point to calculate chords for each point whose located on one edge. Something like that:
def get_structure_vert():
dictionary = {'neibs':[],
'ang_neibs':[],
'sorted_neibs':[]}
return dictionary
def get_structure_edg(edg):
dictionary = {tuple(edg):{'height_chords':[],
'chords':[],
'intersect_chords':[]}}
return dictionary
Nested dictionary also can get confuse :/
For sure you may found a faster/clearer way of doing it :D I keept the information in lists, is confusing but works (also with np).
I did a fast transformation from the contour2d into voronoiArc in case you want to test it, (It creates glitches in complicated situations) https://github.com/vicdoval/sverchok/tree/voronoi_arc_2d
Maybe it is not even the same concept but looks similar isnt it? :D
I tested your node, it is really hard node, a lot of functions and code.)) And it works not as voronoi diagram now. The sense of voronoi is to have equal radius for each point otherwise diagram will not be voronoi. voronoi sense_2018_03_10_04_38.gz I am going to make a more easy node. Main work will do delaunay triangulation, this algorithm we already have. After that I have to only find chords of circles and work will be done.))
:) I did my best clearing the code but you know.. If you want you can search about "variable radius voronoi" or "Weighted Voronoi diagram" it is a pretty interesting topic, maybe not part of what you are searching right now :D https://gist.github.com/81309cb5b52256b163d9e0a8ec6f7b5c
It have appeared really hard goal for me in spite that all math stuff are clear. But however I managed to do something. It is far from the end yet.
Something have gone wrong ))
It looks like nearly working. Process of implementation was really painful. I didn't use any articles about voronoi diagram so I faced with a lot of unpleasant surprises. And it is a little bit strange that it is working in the end.
Ready for test. voronoi with radius7_2018_03_27_11_29.zip
Dividing to buildings based on this algorithm.
@nortikin can you send @Durman invite for collaboration? no one have time to test things from outcomers. Sverchok is just an addon after all.
I don't think it is really necessary. I always can create pull request, isn't it? ))
lovely stuff @Durman !!
invited
@Durman now you can create this template here: https://github.com/nortikin/sverchok/tree/master/node_scripts/SNLite_templates
Ok, I will do it soon.
Result: https://github.com/nortikin/sverchok/files/1851743/voronoi.with.radius7_2018_03_27_11_29.zip I have sum thoughts about creating this algorithm: Creating arc with two points and center: https://gist.github.com/b21c411afde560cf99c5b2f2589ad3c8