Multiple radius choices for circle packing problem

In this part of the code, you can see that it will generate circles with radii between 10 and 30. How can I make it so that it will only generate circles with radius 10 and 30 not the range? Capture

Answers

  • r = 10
    If random number > .5 then r = 30

  • Can you explain a bit more, @koogs? I'm new to js.

  • edited July 2017 Answer ✓

    You want to get two values randomly.

    What koogd did: radius 10 is the default so to speak.

    In the 2nd line he generates a random number (between 0 and 1) and at the same time asks it wether it is bigger than 0.5 using if. This applies to 50% of the cases statistically.

    When the condition is met (keyword then) the default r is changed to 30.

    So you end up with either 10 OR 30.

  • Thank you, @Chrisir !

Sign In or Register to comment.