Very nice indeed! My port to BaCon, as usual I tried to stay as close to the original code as possible, though I had to rename 'y1' because this is a C function (Bessel calculation). Also, I changed 'fx' to a 'def fn', as this function only contained one line.
' Fun Shapes with Pedal Equation.sdlbas [B+=MGA] 2017-03-30
' from Fun shapes from Pedal Eq.bas SmallBASIC 0.12.8 [B+=MGA] 2017-03-30
' inpired by Andy Amaya's screen shots and reference to Superformula
' Here is some experimenting with the pedal equation
' Port to BaCon by PvE - April 2017 - compile using the '-j' option.
include canvas.bac
option vartype float
const xmax = 800
const ymax = 600
window("Fun Shapes with the Pedal Equation", xmax, ymax)
'ra = radian angle
'mx, my multipliers of angle
'e exponent of pedal
'mx, my simple multipliers of the ra
def fn fx(ra, mx, my, e) = pow(( pow(( cos(mx * ra) ), e) + pow(( sin(my * ra) ), e) ), .5)
sub polarPlotter(x, y, ra, rdist, fillTF)
'x, y think of as the origin of the plot
'ra = radian angle
'rdist = radial distance from the "origin"
x1 = x + rdist * cos(ra)
y_1 = y + rdist * sin(ra)
if fillTF then : line(x, y, x1, y_1) : else : circle(x1, y_1, 2, 2, 0) : end if
end sub
thescale = 200 : fillTF = 0 : cn = 1
for e = 2 to 10
for m1 = 1 to 10
for m2 = 1 to 10
if m1 <> m2 then
ink(0,0,0,255)
cls
ink(0x00,0xbb,0xee,0xff)
'circle xmax/2, ymax/2, scale color 12 'for frame of reference red circle with radius 100
text("e = " & str$(e) & " m 1 = " & str$(m1) & " m 2 = " & str$(m2) , 10, 18)
if random(11) = 1 then
r = pow((random(10001)/10000), 2) : g = pow((random(10001)/10000), 2) : b = pow((random(10001)/10000), 2)
for s = 200 to 0 step -1
ink(127+127 * sin(r * cn), 127 + 127 * sin(g * cn), 127 + 127 * sin(b * cn), 255 )
incr cn, .1
for a = 0 to 2 * pi step .001
d = fx(a, m1, m2, e)
polarPlotter(xmax/2, ymax/2, a, s * d, 0)
next
sync
next
else
for a = 0 to 2 * pi step .001
d = fx(a, m1, m2, e)
polarPlotter(xmax/2, ymax/2, a, thescale * d, fillTF)
next
sync
end if
sleep 400
end if
next
next
next