[Grasshopper] How to use Random to output random numbers

[Grasshopper] How to use Random to output random numbers Grasshopper component EN

This article explains how to use Random to output random numbers.

Random1
Random2

On the Grasshopper, it is represented by either of the two above.

Click here to download the Grasshopper file

Please refer to the Terms of Use regarding the use of downloadable data.


↑Youtube Channel

Outputting Random Numbers

Random can be used to output random numbers.

Outputting Random Numbers

Enter a range of numbers in the Random(R).

Initially, Construct Domain is used to create a range of 0~100.

The Random(N) is used to input the number of numbers to be output.

Initially, 10 is entered.

The Random(S) is used to input a seed value number that changes the randomness.

If a number between 0 and 100 is input to the Number Slider, 100 different random numbers can be generated by changing the number.

At first, we entered 20.

Then, in the above image, 10 random numbers were created within the range of 0~100.

with a letter

You can also specify the range of numbers on the Random(R) with a letter.

You can also specify the range in this way by entering a numeric value To numeric value in the Panel.

In the image above, 0 To 100 is entered.

changed the maximum value of the range

I changed the maximum value of the range from 100 to 50.

Then, the output value no longer exceeds 50.

出力される数を増やす

Increasing the number of values on the Random(N) increases the number of numbers output.

This time, we changed the value from 10 to 20.

Now 20 numbers are output.

5 numbers

If the number is set to 5, only 5 numbers are output.

changed the randomness

Changing the value on the Random(S) changed the randomness of the output numbers.

The image above shows the case where the seed value is set to 50.

seed2

This is the case with a seed value of 79.

.

Example of using Random

Example of using Random

Let’s try to create an example like the image above using Random.

Click here to download the Grasshopper file

Please refer to the Terms of Use regarding the use of downloadable data.

Components used
Click to Zoom

Components used: (1) Rectangle ( 2 ) Surface (3) Divide Domain² (4) Isotrim ( 5 ) Area (6) Multiplication (7) Random (8) Scale (9) Deconstruct Brep ( 10 ) Curve (11) Ruled Surface

Rectangle

First, create a rectangle using Rectangle.

This time, enter 100 for the Rectangle’s X and Y values, and set the length of the sides to 100.

Surface

Next, connect the Rectangle to the Surface to make the rectangle into a surface.

divide the surface

We then use Divide Domain² and Isotrim to divide the surface.

Connect Surface to the Divide Domain²(I).

This time, input 10 to the Divide Domain²(U and V) and divide the surface by 10 x 10.

Connect the surface to the Isotrim(S) and connect Divide Domain² to the Isotrim(D).

The surface is now divided

The surface is now divided.

Area

Connect Isotrim to Area to get the center point of each divided surface.

Multiplication

We then connect 10, the number of divisions used in Divide Domain², to the Multiplication(A and B) and multiply.

Then, set the R range of Random to 0~1.

Connect Multiplication to the Random(N).

Input an appropriate seed value to the Random(S).

A random number between 0 and 1 is then created.

This will be the multiplying factor when changing the scale later.

Scale

Then, connect Isotrim to the Scale(G).

Connect the Area(C) to the Scale(C).

Connect Random to the Scale(F).

Now the size of each surface changes randomly.

extract the borders

Then, use Deconstruct Brep on the original surface and the resized surface to extract the borders.

Then, we connect each Curve to the Deconstruct Brep(E).

the border has been extracted

As you can see, the border has been extracted.

Ruled Surface

Finally, connect the two Curves to Ruled Surface to create a surface that connects the two borders.

This completes the process.

List of Grasshopper articles using Random component↓

Comment

Translate »