Create a Sin wave line with Processing

Posted by Nintari on Stack Overflow See other posts from Stack Overflow or by Nintari
Published on 2010-03-07T06:51:34Z Indexed on 2011/01/12 14:53 UTC
Read the original article Hit count: 239

Filed under:
|
|

Hey everybody, first post here, and probably an easy one.

I've got the code from Processing's reference site:

float a = 0.0;
float inc = TWO_PI/25.0;

for(int i=0; i<100; i=i+4) {
  line(i, 50, i, 50+sin(a)*40.0);
  a = a + inc;
}

http://processing.org/reference/sin_.html

However, what I need is a line that follows the curve of a Sin wave, not lines representing points along the curve and ending at the 0 axis. So basically I need to draw an "S" shape with a sin wave equation.

Can someone run me through how to do this?

Thank you in advance, -Askee

© Stack Overflow or respective owner

Related posts about processing

Related posts about waveform