This program randomly generates a Lissajous curve or figure.
Definition of Lissajous figure: any of an infinite variety of curves formed by combining two mutually perpendicular simple harmonic motions, commonly exhibited by the oscilloscope, and used in studying frequency, amplitude, and phrase relations of harmonic variables (Merriam/Webster)
Origin and Etymology of lissajous figure – Jules A. Lissajous †1880 French physicist
Also known in mathematics as a parametric equation, parametric equations of a curve express the coordinates of the points of the curve as functions of a variable, called a parameter. For example, are parametric equations for the unit circle, where t is the parameter. Together, these equations are called a parametric representation of the curve.
These are commonly seen in oscilloscopes and in the 1800's used to be drawn by hand or a mechanical device called a harmonograph (a mechanical apparatus that employs pendulums to create a geometric image. The drawings created typically are Lissajous curves, or related drawings of greater complexity.)
This is my first stab in a long time at converting these formulas for such graphing scenarios such as raw output from sensors using Internet of Things, which are mostly converted and represented in graphical form.
If you turn off the graphics and change the DRAW LINE to a PRINT statement, you will see the raw values that most sensors produced, which much be converted into something with a meaning, like a graphic, often in realtime.
For this program I have created a random generator to simulate different results I may get (not accurate for sensor data, but accurate for the mathematical principle of Lissajous figures/curves) are representative) and produced the curve graph accordingly.
To get different graphs, densitites, etc., you can play around with the variables f1, f2 and c. You can also change the value of the time loop to see how the lengt of time affects the displays.
This is my first attempt in a very long time at writing such a program, and while TechBASIC is where this final product will reside, it doesn't have as robust a community to help me point out errors or show me tricks that are easier to use.
I haven't yet converted this code to TechBASIC as I first need to determine the sensor that I first choose to program for, but most graphing will be similar to each other.
Sources: https://en.m.wikipedia.org/wiki/Lissajous_curve
https://en.m.wikipedia.org/wiki/Parametric_equation
https://en.m.wikipedia.org/wiki/Harmonograph
The next is a challenge, if anyone else is interested, is called Lissajous Knots. Where Lissajous Curves are based on two points, the knots are based on 3 points, and inlucde both itegers and real numbers as parameters.
To get more information on the Lissajous Knots, check out: https://en.m.wikipedia.org/wiki/Lissajous_knot as well as other materials.
Code: Select all
/* PROGRAM: Lissajous Curves v1.0
George McGinn
May 30, 2017
V1.0 – Initial Program (sizing for iPhone not working)
Definition of Lissajous figure: any of an infinite variety of curves formed by combining two mutually perpendicular simple harmonic motions, commonly exhibited by the oscilloscope, and used in studying frequency, amplitude, and phrase relations of harmonic variables (Merriam/Webster)
Origin and Etymology of lissajous figure – Jules A. Lissajous †1880 French physicist
Also known in mathematics as a parametric equation, parametric equations of a curve express the coordinates of the points of the curve as functions of a variable, called a parameter. For example, are parametric equations for the unit circle, where t is the parameter. Together, these equations are called a parametric representation of the curve.
*/
SBInit:
GRAPHICS
GRAPHICS CLEAR
SHADOW OFF
RANDOMIZE
GRAPHICS CLEAR 1,1,1
OPTION TEXT POS NORMAL
SET ORIENTATION LANDSCAPE
SET TOOLBAR OFF
DRAW LINECAP ROUND
DRAW SIZE 2
SBBegin:
a=200!b=200
f1=RND(20)!f2=RND(20)
c=RND(100)
X$="X=SIN(2*3.14*"&f1&"*t)"
Y$="Y=SIN(2*3.14*"&f2&"*t+"&C&")"
DRAW COLOR 0,0,0
DRAW TEXT "Lissajous Curve" AT 1,5
DRAW TEXT X$ AT 1,25
DRAW TEXT Y$ AT 1,45
SHADOW ON
SHADOW OFFSET 2,2
SBLoop:
FOR time=0 to 100000 '*** The longer the time, the more complete the pattern becomes
t=time/20
d=2*3.14*f1*t
dd=sin(d)
x=a*dd
aa=2*3.14*f2*t+c
cc=sin(aa)
y=b*cc
x=x+400
y=300-y
DRAW COLOR 1,0,0
DRAW LINE x,y TO x+1,y+1
NEXT time