B4J Tutorial Drawing "Waves"with Epicycles

Have converted this Github project to B4J. Sure you will figure it out:
1. Select from the ComboBox to draw Square/Triangle
2. Move the Slider to increase/decrease the number of Epicycles to draw the "wave" with
3. Click on the CheckBox(es) to enable/disable the vectors and circles.

In Class Cycle of the B4J project there are two more Java code waves that you can add (have commented them out) - leaving it up to you as it is reasonably easy to add them

This is a square wave that was drawn with 81 Epicycles (the more Epicycles you select, the closer the approximation to the square wave - move the slider up/down to see the change in the live drawing.)

You will need jCanvasExt (jar and xml - both attached to this posting) by @klaus . Download them and copy them to your B4J additional library folder.

1704193439123.png


Triangle Wave using 100 epicycles
1704193682107.png
 

Attachments

  • b4jFourier2.zip
    5.4 KB · Views: 46
  • jCanvasExt.jar
    5.1 KB · Views: 45
  • jCanvasExt.xml
    35.5 KB · Views: 53

Johan Schoeman

Expert
Licensed User
Longtime User
It's interesting to see the gibbs effect during the square drawing.
.....the difficulty inherent in approximating a discontinuous function by a finite series of continuous sinusoidal waves....
 

Johan Schoeman

Expert
Licensed User
Longtime User
Have added Sawtooth and Semicircle (take note of post #1 for the jar and xml that you will require) :

Sawtooth with 100 epicycles:
1704619963228.png


Semicircle with 100 epicycles:
1704620035017.png
 

Attachments

  • b4jFourier2.zip
    5.4 KB · Views: 31
Top