Hi Josephhh,
Thanks for your quick answer but:
When I declare variables in void draw(); I don’t have good value of w1 and w2, unlike before setup() with w1=0.1 and w2=0.11.
I don’t understand why?
float w1, w2;
int x;
int Um=100;
int Vm=100;
int num=1000;
float phiU= 2*PI;
float phiV= 2*PI;
float X1t, X2t;
void setup() {
size (1000, 800);
frameRate(30);
colorMode(RGB, 255, 255, 255, 100);
}
void draw(){
//For example
w1 = 0.1;
w2 = 11/10*w1;
x=x+1;
X1t= Um/2* cos (w1*x+phiU)-Vm/2*cos (w2*x+phiV);
X2t= Um/2* cos (w1*x+phiU)+Vm/2*cos (w2*x+phiV);
//Draw something...
noStroke();
fill(0,num,50);
ellipse (x, X1t+200, 5,5);
fill(0,50,num);
ellipse (x, X2t+400, 5,5);
println(w1);
println(w2);
}
You are trying to have both constants and variables at the same time, which is not possible.
If you plan to have w1 depending of the mouse value, you need to affect w1 and w2 in the draw function.
Otherwise just declare w1 and w2 as constants outside the functions.
Yep Guys.
Thanks you all.
It works perfectly, now I have to find the formula to simulate, interaction between several pulsation, not only with two.
I’m looking for a model which simulate several N coupled oscillator and not just two.
If you have any idea, I will study it.
Thanks again.
lucky you like it,
one way would be just to create random noise and add it,
or more sin waves,
here you should study the harmonics…
like how to make a saw or rectangle wave form by adding harmonics,
now from the coding there could be also a interesting way to use
inverse FFT instead manually adding sinus ( but its actually the same. )
and possibly adding key strokes to start stop adding NOTES
like a piano.
and when your created wave is very beautiful,
you might want to hear it too.