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 & HelpSyntax Questions › Using noise with PVector
Page Index Toggle Pages: 1
Using noise with PVector (Read 797 times)
Using noise with PVector
Sep 22nd, 2009, 6:20am
 
Hello guys, i would like to have your time and ask a question..

I had this Particle class with loc,vel,acc using PVector, and i want to give acc some noise value, i want my particles to accelerate in a flow field, moving randomly, i could give acc a random() value but i want to do it with perlin noise so...

theres an applyForce() function in the class which is like

void applyForce(PVector force)
{
   force.div(mass);
   acc.add(force);
}


but since the force is PVector and noise is float, i just couldnt figure out what to do, it's been a day soi would love to hear your reccomendations..

thanks for your time,
Metin
Re: Using noise with PVector
Reply #1 - Sep 22nd, 2009, 1:51pm
 
Look at the reference:
http://processing.org/reference/PVector_mult_.html

Maybe you could use something like
Code:
acc.add(PVector.mult(force, noise())); 

Re: Using noise with PVector
Reply #2 - Sep 22nd, 2009, 3:20pm
 
indeed, but i still dont know what to put in noise() method to create a noise flow-field, i dont want it to move random Sad
Re: Using noise with PVector
Reply #3 - Sep 23rd, 2009, 9:00am
 
As seen in the reference, noise() takes a float as argument. Increase this float on each frame to get a smooth noise curve :

Code:
float p = 0.0;
void draw() {
p += 0.01;
acc.add(PVector.mult(force, noise(p)));
}
Page Index Toggle Pages: 1