This browser has no WebGPU, so the sketch cannot run here. The program is below, and it runs in a current Chrome, Edge or Safari.

Harmonic Oscillation

Plot vibrating strings at successive harmonic frequencies

Open in new tab ↗ · oscillationtrigonometry

///////////////////////////////////////////////////////////////
// harmonic-oscillation
// Plot vibrating strings at successive harmonic frequencies.
///////////////////////////////////////////////////////////////

&time = mlt(step, 0.03);
&strings = 7;
&localY = frc(mlt(C.y, &strings));

// divide the vertical space to the number of strings
// octave spacing set to 1x
&harmonic = add(flr(mlt(C.y, &strings)), 1);

// apply the sine function 
&shape =
sin(
   mlt(
      C.x,
      mlt(&harmonic, TWO_PI)
   )
);

// apply motion
&motion =
sin(
   mlt(
      &time,
      &harmonic
   )
);

// the line function to be tested 
&line = add(0.5, mlt( &shape, &motion, 0.25));

#A {
   dim = (512,512,1);
   coord_dom = UNIT;
   // tests each coordinate for distance to the line
   run =
   sml(
      abs(sub(&localY, &line)),
      0.01
   );
}

~A { col = #A;}