Deux angles sont utilisés : le premier s’occupe de l’oscillation, le deuxième de l’amplitude de cette oscillation. Le déplacement horizontal est constant. On obtient donc ceci :

float ang1=0;
float osc1=0.07; // vitesse d'oscillation 1
float ang2=0;
float osc2=0.001; // vitesse d'oscillation 2
float x=0;
float vitesse_x=0.1; //déplacement sur l'axe horizontal
void setup() {
size(1200, 400);
strokeWeight(2);
background(255);
smooth();
}
void draw() {
translate(0, height/2);
point(x, sin(ang1)*(sin(ang2)*(height*0.45))); // le calcul
ang1+=osc1;
ang2+=osc2;
x+=0.1;
if (x> width) { // nettoyer et recommencer
saveFrame();
background(255);
x=0;
}
}