Randomizing a value

   3736   4   0
User Avatar
Member
113 posts
Joined: July 2005
Offline
Hello Everybody,



I wonder how to randomize a value between a fork of 2 values.

For example I want a radom value like that :

/obj/model/box1/sizey < my random value < /obj/model/box2/sizey

I want the value to always be in that fork without clamping to the max/min



Thanks in advance !

Julien
User Avatar
Member
121 posts
Joined: July 2005
Offline
take a look at the fit function (type “exhelp fit” in the textport)

fit(rand($PT), 0, 1, ch(“../box1/sizey”), ch(“../box2/sizey”))

Hope this helps

Achim
User Avatar
Member
941 posts
Joined: July 2005
Offline
Hi Undertaker,

Assuming that “my random value” is in the range , then you can try:

randval * (max-min) + min

or

fit01(randval,min,max)

(in both cases “randval” is the random number)


Cheers!

EDIT: Sheesh! This is the second time today that I post something at the same time as someone else … sorry Achim (that's it; no more posting for me today! )
Edited by - May 13, 2004 14:19:58
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
412 posts
Joined: July 2005
Offline
also, i would think you could use clamp(), but not sure..didn't test it but worth a shot..
Dave Quirus
User Avatar
Member
113 posts
Joined: July 2005
Offline
thank you guys for helping !

Mario, I used fit01(randval,min,max), it works perfectly, thanks !
  • Quick Links