blog.x-e.ro / random: page 2 of 38
as3 :: random number in flash
just another take on a classic piece of code. the pseudo-random number generator. this one is almost the same, just a slightly diffrent algorithm.
private function randomizer(low:Number, high:Number):Number {
var num:Number = high-low;
return (Math.random()*num)+low;
}
then use it...
var x:Number = randomizer(5, 50);
i <3 randomization
demos :: with papervision3D
we were discussing recursive algorithms and chaos theory at work yesterday. when one of the chemistry professors brought up the lorenz attractor. he was trying to draw one on the white board for about 10 minutes until i decided it would be easier to draw in flash, lol!
after a quick conversation w/ andy zupko about the new Line3D object, and my new CanvasView3D component for papervision, i made a sweet lorenz attractor!
the algorithm is super simple:
x1 = x0 + h * a * (y0 - x0);
y1 = y0 + h * (x0 * (b - z0) - y0);
z1 = z0 + h * (x0 * y0 - c * z0);
here is my asp.net randomizer class based on the c R250/512 shift-register sequence random number generator, by kirkpatrick and stoll and published (j. computational physics, vol 40, pp. 517-526) with an added a pseudo-random class redefinition and buffer overflow protection.
example usage:
randomizer x = new randomizer();
int num = x.random();
here a nice little one liner. this function returns a random number between a user supplied range.
function randomizer (low:Number, high:Number):Number {
return Math.floor(low + (Math.random() * (high-low)));
}
example useage, will return a number between 5 - 50.
var x:Number = randomizer(5, 50);
i was having some trouble at work creating form buttons with graphics for reset buttons. i just thought someone might be interested in my non-javascript solution:
<button style="background: none; border: none;">
<img src="reset.jpg" alt="" />
</button>
people look at an oil painting and admire the use of brushstrokes to convey meaning. people look at a graffiti painting and admire the use of a drainpipe to gain access...
banksy
quotes :: i don't know what else to say
x: what did yew do this weekend?
s: i gave rumpelstilskins a cauliflower ear.
x: i should have never asked.