Grasshopper

algorithmic modeling for Rhino

Hi Guys,
Would you know if there is a "random" function in VB.net.
I am having trouble with the "random" component used by Grasshopper:
http://www.grasshopper3d.com/forum/topics/regular-to-chaotic-grid
Many thanks,
Arthur

Views: 626

Replies to This Discussion

Hi Arthur,

example random from integer 0-10


Dim rnd As Random = New Random()
Dim minValue As Integer = 0
Dim maxValue As Integer = 10

A = rnd.Next(minValue, maxValue)


[u
Hi Arthur,

Attached definition shows 2 ways to generate random numbers (double). One using GH component and the other using VB component.
Attachments:
I didn't open Rajaa's attachments, perhaps they list the same.

Its the same as in Rhino Script: simply do a rnd*x.

rnd will give you a random number between 0 and 1 everytime.
x can be any multiplier you want that can help you set the upper limit of the output with a default lower limit of 0. If you want things between a specific range of numbers, you can use:

range = upperlimit - lowerlimit
number = rnd * range

if you need a series of random numbers, just put it in a for loop.
Don't forget to add the lowerlimit to the number:
number = lowerlimit + rnd*range
yup... thanks for correction!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service