randomize between two numbers

   6937   7   4
User Avatar
Member
32 posts
Joined: Nov. 2018
Offline
hello. i can't figure out how to get a random value between two numbers. in maya i just type rand(8,10).
how can i do that in houdini? i couldn't find anything helpful in the functions list.
User Avatar
Member
402 posts
Joined: April 2017
Offline
in VEX:
float foo = fit01(rand(seed), 8, 10);
where seed is the random seed (often @ptnum in a point wrangle)

in hscript expressions:
fit01(rand(@ptnum), 8, 10)
assuming the point number is the random seed
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
32 posts
Joined: Nov. 2018
Offline
thank you for your reply. the code seems working. but somehow doesn't solve my objective…
User Avatar
Member
402 posts
Joined: April 2017
Offline
Maybe you ought to mention what your objective is?
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
32 posts
Joined: Nov. 2018
Offline
i want to emit a ring of particles. so i created an emitting object, have keyed emission so it bursts for one frame only, and then set the velocity variance to x=10 and z=10. but so the particles are emitting not as a ring but as a circle. my thought was that the variance goes from 0 to 10, but when i have used your code nothing changed. they are still moving as a circle filling whole radius.
User Avatar
Member
81 posts
Joined: Dec. 2020
Offline
Hello guys,

Jumping here because I have a similar problem.
I have this Point Replicate set to 20 to uprase my Vellum Grain.

How can I replicate a random number between two values on a per point basis?

Thank you
User Avatar
Member
192 posts
Joined: Oct. 2018
Offline
You could do like toadstorm said and use a point wrangle with a code like this:
f@random = fit01( rand(@ptnum), 8, 10 );

Or use the attribute randomize sop set to Set Value and specify the min/max values. If you want a float value, change the Dimensions to 1.
User Avatar
Member
81 posts
Joined: Dec. 2020
Offline
mkps
You could do like toadstorm said and use a point wrangle with a code like this:
f@random = fit01( rand(@ptnum), 8, 10 );

Or use the attribute randomize sop set to Set Value and specify the min/max values. If you want a float value, change the Dimensions to 1.

Thanks mkps, someone on odforce told me about this new node (attribute adjust integer) that does just that!

https://forums.odforce.net/topic/48337-how-to-randomly-replicate-points-between-two-values/ [forums.odforce.net]
  • Quick Links