Random Rectangle from List of points


#1

Hey guys, Im playing around with my definition a while now, but I just cant wrap my head around this issue.

I want to connect 4 random points of a List into a rectangle.


(every colour stands for another random outcome through a seeder slider)

my definition only works for the specific seed. When altering the Seed, it sometimes uses only 3 points or connect the points in a “false” order. most likely my approach have major issues and lacks of knowing how to sort and refine the lists probably.

I hope you can help me with that newbish question.

random_rectangle.gh (8.0 KB)


#2

Hi,
not sure if it is what you want.


(David Rutten) #3

\{4, 4, 4, 4\} is a perfectly acceptable random sequence. There is no guarantee that all numbers in the range will occur before you start seeing the same number again. If you get the same number twice your quad will degenerate into a triangle. The odds of any number occurring in a random sequence is \frac{1}{R} with R being the length of the range (12 in your case). So once the first number is picked, the odds that the second number will be the same as the first are \frac{1}{12}. When you pick a third number, the odds that it will be the same as either the first or the second are \frac{2}{12}. Pick a fourth and the odds of any collision are \frac{1}{12} + \frac{2}{12} + \frac{3}{12} = \frac{6}{12} = \frac{1}{2}.

ho, dinner is served, I’ll continue this in a bit.


#4

Your Method works pretty well @Baris, thx for that. Also so small and clear compared to what I came up with.

Also I see your Point @DavidRutten and that explains the triangle degeneration pretty good to me (should have paid more attention in stochastics :slight_smile:) . So I’d need to extract picked variables and subtract them from the List feeding the random component? That would be a kind of feedbackloop then right? How I’d do that or is there a workaround?

Enjoy your Lunch!


(David Rutten) #5

I wouldn’t generate a list of random numbers in this case. Instead, I’d generate a list with all the allowed numbers (using the Series component), and then jitter that list using strength=1. You can still use your Seed value with Jitter. This will shuffle your ordered list of numbers, so you then just have to extract a sublist of four values (always the first four to keep it simple). This may still yield a list that is not going around the circle, for example \{5, 10, 7, 2\}. The third number is in between the first and second, so you get a bow-tie shaped quad. You can fix this by sorting your sub-list before using it.


#6

Used your advise on Baris’s proposed definition and its doing exactly what I need. Thx for your awesome help!