iDevGames Forums
Random Point Distribution Problems - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Random Point Distribution Problems (/thread-1457.html)

Random Point Distribution Problems - Oddity007 - Apr 14, 2009 09:44 AM

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?

Random Point Distribution Problems - ThemsAllTook - Apr 14, 2009 10:57 AM

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...

Random Point Distribution Problems - Oddity007 - Apr 14, 2009 01:43 PM

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...).

Random Point Distribution Problems - TythosEternal - Apr 14, 2009 10:35 PM

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!