Random Point Distribution Problems

Posts: 227
Joined: 2008.08
Post: #1
For a particle engine I need to randomly distribute points within a maximum spread.

My method is this:
for each particle in particleArray do:

However it doesn't seem to be working, so are there any problems with how I am doing it?
Is there any better method?
Quote this message in a reply
Posts: 1,563
Joined: 2003.10
Post: #2
What are you trying to achieve, and in what way does that implementation fall short of the intended result?

The main thing that pops out to me is that if your random function does what its name implies, you won't get any negative numbers, so you may want to do ((randomFrom0To1() - 0.5) * 2) instead. With more context, we'd probably be able to give you a better answer...
Quote this message in a reply
Posts: 227
Joined: 2008.08
Post: #3
I already figured this one out, it had to do with me not taking into consideration that intValue%100/100 will always give 0 as there is no fractional part and it is not implicitly made float (Argh!!! The perils of being high on floats! Hah ha...).
Quote this message in a reply
Posts: 46
Joined: 2008.10
Post: #4
Because I'm slightly bored:

You may also want to consider incorporating some form of a distribution function, probably Gaussian, to give your particle system a more realistic look.

Glad you fixed your problem, though!

"Who's John Galt?"
Quote this message in a reply
Post Reply