Lissajous curves are defined by x = a*sin(theta) and y = b*sin(theta). I created a macro enabled Excel spreadsheet to draw them. I can send it to anyone with instructions on how to use it. The spreadsheet uses the VBA code below.
I'll be glad to answer any questions about this. Hope this post helps.
- Tom
Public Sub lissajous()
'Creates data points to draw a Lissajous curve
Dim a As Integer, b As Integer
Dim theta As Double, stepsize As Double, iter As Long
Dim pi2 As Double
'Read a and b from the spreadsheet
'if they are not positive then say so and exit
a = Int(Val(Cells(3, 2).Value))
b = Int(Val(Cells(4, 2).Value))
If a <= 0 Or b <= 0 Or Cells(9, 12).Value Or Cells(10, 12).Value Then
MsgBox "a and b must be positive integers. Try again.", vbExclamation
Else
'Initialize counters, steps, clear ranges and set headings.
theta = 0#
iter = 0
stepsize = Val(Cells(5, 2).Value)
pi2 = 2 * WorksheetFunction.Pi
Range("D:G").ClearContents
Cells(1, 4).Value = "Iteration"
Cells(1, 5).Value = "Step"
Cells(1, 6).Value = "Sin(" & CStr(a) & "* theta)"
Cells(1, 7).Value = "Sin(" & CStr(b) & "* theta)"
'Loop through all values in 0 to 2pi with a stepsize of stepsize
'Create data for plotting
While theta <= pi2
iter = iter + 1
Cells(1 + iter, 4).Value = iter
Cells(1 + iter, 5).Value = theta
Cells(1 + iter, 6).Value = Sin(a * theta)
Cells(1 + iter, 7).Value = Sin(b * theta)
theta = theta + stepsize
Wend
End If
End Sub
I'll be glad to answer any questions about this. Hope this post helps.
- Tom
Public Sub lissajous()
'Creates data points to draw a Lissajous curve
Dim a As Integer, b As Integer
Dim theta As Double, stepsize As Double, iter As Long
Dim pi2 As Double
'Read a and b from the spreadsheet
'if they are not positive then say so and exit
a = Int(Val(Cells(3, 2).Value))
b = Int(Val(Cells(4, 2).Value))
If a <= 0 Or b <= 0 Or Cells(9, 12).Value Or Cells(10, 12).Value Then
MsgBox "a and b must be positive integers. Try again.", vbExclamation
Else
'Initialize counters, steps, clear ranges and set headings.
theta = 0#
iter = 0
stepsize = Val(Cells(5, 2).Value)
pi2 = 2 * WorksheetFunction.Pi
Range("D:G").ClearContents
Cells(1, 4).Value = "Iteration"
Cells(1, 5).Value = "Step"
Cells(1, 6).Value = "Sin(" & CStr(a) & "* theta)"
Cells(1, 7).Value = "Sin(" & CStr(b) & "* theta)"
'Loop through all values in 0 to 2pi with a stepsize of stepsize
'Create data for plotting
While theta <= pi2
iter = iter + 1
Cells(1 + iter, 4).Value = iter
Cells(1 + iter, 5).Value = theta
Cells(1 + iter, 6).Value = Sin(a * theta)
Cells(1 + iter, 7).Value = Sin(b * theta)
theta = theta + stepsize
Wend
End If
End Sub