Why on earth are my sine waves doing this?
in
Contributed Library Questions
•
7 months ago
I need to make some sine waves that move, but cannot seem to get a pure wave. Instead there's an odd part initially as you can see in the picture above. I figure that it's something in the mathematics that I'm missing, some help would be great. Here's the code:
- import traer.physics.*;
- ParticleSystem physics;
- Particle p;
- void setup(){
- stroke(255);
- strokeWeight(1);
- size(500,500,P3D);
- background(0);
- physics = new ParticleSystem( 0.0, 0.0 );
- int pitch = 440;
- for(float i = 0.0; i<width; i=i+0.1){
- p = physics.makeParticle(1,i,height/2+sin(pitch*TWO_PI*i)*20,0);
- //p.velocity().set(0.1,0,0);
- }
- }
- void draw(){
- background(0);
- physics.tick();
- for(int i = 1; i<physics.numberOfParticles(); i++){
- p = physics.getParticle(i);
- float x = p.position().x();
- float y = p.position().y();
- point(x, y);
- }
- }
- void mousePressed(){saveFrame("line-######.png");}
Thanks,
Adam
1