While Loop Problem

   1134   8   2
User Avatar
Member
20 posts
Joined: 10月 2021
Offline
Hi everyone, so I want to create a VEX code where I can scatter random circles into this grid without intersection. I am a little bit stuck while I'm doing the "While()" loop. Basically, what I need is that if the circles are intersecting, I need it to change the scattered seed. Does anybody know how to fix it? Thanks in advance!

Attachments:
Example.png (1.0 MB)
Random Space Filling.hipnc (133.0 KB)

User Avatar
Member
123 posts
Joined: 8月 2017
Offline
something like this Or?

Attachments:
smRECsssdddttt.gif (722.9 KB)

Conservation of Momentum
User Avatar
Member
670 posts
Joined: 9月 2013
Offline
This tutorial might help:
https://youtu.be/Y1UC3T9l15U [youtu.be]
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
20 posts
Joined: 10月 2021
Offline
cncverkstad
something like this Or?
Actually, I'm trying to do it like this. http://paulbourke.net/fractals/randomtile/ [paulbourke.net] . By the way, that's quite an interesting result you got there. Is it okay if you send the hip file as well?
Edited by martinalex - 2023年6月2日 07:14:57
User Avatar
Member
20 posts
Joined: 10月 2021
Offline
Konstantin Magnus
This tutorial might help:
https://youtu.be/Y1UC3T9l15U [youtu.be]
Thank you for the link. It is quite similar to what my goal is, which is like this, http://paulbourke.net/fractals/randomtile/ [paulbourke.net] . The only problem that I'm seeing is that it uses a solver for it. I'm wondering if it can be done without a solver.
User Avatar
Member
478 posts
Joined: 8月 2014
Offline
Take a look at @tamte's example file: https://www.sidefx.com/forum/topic/18255/#post-85827 [www.sidefx.com]
User Avatar
Member
20 posts
Joined: 10月 2021
Offline
ajz3d
Take a look at @tamte's example file: https://www.sidefx.com/forum/topic/18255/#post-85827 [www.sidefx.com]
Thanks for the link. It is quite similar to what I'm aiming for, however, I do notice that there is not much size difference between the circles, and there are still some empty spaces that need to be filled.
User Avatar
Member
480 posts
Joined: 7月 2005
Offline
Here is a modification of your file. The algorithm should be similar to the algorithm in the link you have given.
In fact it is repeating, to find a random location on a grid, where there is "enough" space to find a circle with a specific radius. The problem is, that the remaining space can get very small, that it is almost impossible to find a valid position for the next circle, because the probability is getting smaller with each circle and there is no guarantee that it finds such a position. So in this case it might be better to omit this circle and try another (smaller) one.

Attachments:
Random_Space_Filling_mod.hipnc (147.6 KB)

User Avatar
Member
20 posts
Joined: 10月 2021
Offline
Aizatulin
Here is a modification of your file. The algorithm should be similar to the algorithm in the link you have given.
In fact it is repeating, to find a random location on a grid, where there is "enough" space to find a circle with a specific radius. The problem is, that the remaining space can get very small, that it is almost impossible to find a valid position for the next circle, because the probability is getting smaller with each circle and there is no guarantee that it finds such a position. So in this case it might be better to omit this circle and try another (smaller) one.
Wow, thank you so much for your help. This is much harder than I think it was supposed to be. Yeah, I guess that it is better and faster to omit the circle than keep finding a random position until we found the valid one.
  • Quick Links