We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Using noise for turbulence fields
Page Index Toggle Pages: 1
Using noise for turbulence fields (Read 635 times)
Using noise for turbulence fields
Jan 8th, 2010, 6:53am
 
Hi,

I created a particle system in processing but now I'm having trouble integrating some kind of turbulence field. My idea was to use the noise function like this:
Code:

for (int q=particles.size()-1; q >=0; q--){
Particle p = (Particle) particles.get(q);
p.update();
p.v.add(gravity);
float noiseVal = noise(p.loc.x*0.01,p.loc.y*0.01, evolution);
noiseVal -= 0.5f;
noiseVal *=10;
p.p.x+=noiseVal;
p.p.y+=noiseVal;

if (p.isDead()){
particles.remove(q);
}
}


It does work, but I think it could be better. The main problem is, that the particles always move linear because the noiseVal is always the same for x and y.
Do you have any ideas how to "really" implement a turbulence field?
Re: Using noise for turbulence fields
Reply #1 - Jan 9th, 2010, 2:19am
 
Hi
First thoughts:
-  could you split your noiseVal into noiseValX and noiseValY, and make each of these different values?

-  I'd be tempted to try randomising those values:
Code:

float noiseVal = noise(p.loc.x * random(0.01), p.loc.y * random(0.01), evolution);


- research into turbulence might show that it affects in all directions - you have it acting in only one x and one y direction, so something like this might be more realistic:
Code:

float noiseVal = noise(p.loc.x * random(-0.01, 0.01), p.loc.y * random(-0.01, 0.01), evolution);

or, since I loathe magic numbers:
Code:

float noiseVal = noise(p.loc.x * random(minNoiseX, maxNoiseX), p.loc.y * random(minNoiseY, maxNoiseY), evolution);


-  and if p.loc.x refers to its location, adding rather than multiplying by the noise value might be more appropriate, otherwise the further to the bottom right the particle is, the more it is affected.

Any help?
I'd be interested in seeing the finished code when you're done.
string
Page Index Toggle Pages: 1