How to create a sine wave in processing?
问题 I would like to create a sine wave using vectors (as I am using box2d ). So far I have (in void draw() ) Vec2 mov2 = new Vec2(sin(angle)*scalar,0); for (int j = 0; j <= 10; j++) { bridge.particles.get(j).body.setLinearVelocity(mov2); } where bridge is a chain of particles . However, this makes all the particles move back and forth at the same time whereas I would like to move like a sine wave so that each particle moves just slightly after the previous one. 回答1: You need to add some sort of