Post by tsh73 on Nov 22, 2019 21:53:03 GMT
You know? If you go to Wolfram Alpha site
and enter "cat curve" into edit box - you'll get picture of a cat
And whole page of formulas supposedly providing this graph.
Really, nice formulas to scare people
Formulas could be downloaded as text
and with little search/replace made useful in LB/JB
So - I've got this
and enter "cat curve" into edit box - you'll get picture of a cat
And whole page of formulas supposedly providing this graph.
Really, nice formulas to scare people
Formulas could be downloaded as text
and with little search/replace made useful in LB/JB
So - I've got this
global width, minX, maxX, height, minY, maxY
nomainwin
open "catCurve" for graphics as #grFunc
print #grFunc, "trapclose [trapcloseLabel]"
print #grFunc, "home ; down ; posxy x y"
'x, y give us width, height
width = 2*x : height = 2*y
pi = acs(-1)
'parametric plot
t0=0
tk=2*pi
n=100'00
'
n = 300 'nPoints
h = (tk-t0)/n
'get x, y bounds
a = 1e10
b = -1e10
minY = 1e10
maxY = -1e10
for t = t0 to tk step h
x = x(t)
if x< a then a = x
if x> b then b = x
y = y(t)
if y< minY then minY = y
if y> maxY then maxY = y
next
minX = a : maxX = b
'print "ymin, ymax ", minY, maxY
'axes
xxmin = sx(a) : xxmax = sx(b) : y0 = sy(0)
print #grFunc, "line ";xxmin;" ";y0;" "; xxmax;" ";y0 'horiz from A to B
print #grFunc, "place ";xxmax-15;" ";y0-5
print #grFunc, "\X"
yymin = sy(minY) : yymax = sy(maxY) : x0 = sx(0)
print #grFunc, "line ";x0;" ";yymin;" "; x0;" ";yymax 'vert ymin to ymax
print #grFunc, "place ";x0-15;" ";yymax+15
print #grFunc, "\Y"
x = sx(x(t0))
y = sy(y(t0))
print #grFunc, "place ";x;" ";y
for t = t0 to tk step h
y = sy(y(t))
xx = sx(x(t))
print #grFunc, "goto "; xx; " "; y
next
print #grFunc, "flush"
wait
end
[trapcloseLabel]
close #grFunc
end
'******************************************
'sample function
function x(t)
'x = 100*cos(t)
x = 0 -(721 *Sin(t))/4 + 196/3 *Sin(2 *t) - 86/3 *Sin(3 *t) - 131/2 *Sin(4 *t) _
+ 477/14 *Sin(5 *t) + 27 *Sin(6 *t) - 29/2 *Sin(7 *t) + 68/5 *Sin(8 *t) _
+ 1/10 *Sin(9 *t) + 23/4 *Sin(10 *t) - 19/2 *Sin(12 *t) - 85/21 *Sin(13 *t) _
+ 2/3 *Sin(14 *t) + 27/5 *Sin(15 *t) + 7/4 *Sin(16 *t) + 17/9 *Sin(17 *t) _
- 4 *Sin(18 *t) - 1/2 *Sin(19 *t) + 1/6 *Sin(20 *t) + 6/7 *Sin(21 *t) _
- 1/8 *Sin(22 *t) + 1/3 *Sin(23 *t) + 3/2 *Sin(24 *t) + 13/5 *Sin(25 *t) _
+ Sin(26 *t) - 2 *Sin(27 *t) + 3/5 *Sin(28 *t) - 1/5 *Sin(29 *t) _
+ 1/5 *Sin(30 *t) + (2337 *Cos(t))/8 - 43/5 *Cos(2 *t) + 322/5 *Cos(3 *t) _
- 117/5 *Cos(4 *t) - 26/5 *Cos(5 *t) - 23/3 *Cos(6 *t) + 143/4 *Cos(7 *t) _
- 11/4 *Cos(8 *t) - 31/3 *Cos(9 *t) - 13/4 *Cos(10 *t) - 9/2 *Cos(11 *t) _
+ 41/20 *Cos(12 *t) + 8 *Cos(13 *t) + 2/3 *Cos(14 *t) + 6 *Cos(15 *t) _
+ 17/4 *Cos(16 *t) - 3/2 *Cos(17 *t) - 29/10 *Cos(18 *t) + 11/6 *Cos(19 *t) _
+ 12/5 *Cos(20 *t) + 3/2 *Cos(21 *t) + 11/12 *Cos(22 *t) - 4/5 *Cos(23 *t) _
+ Cos(24 *t) + 17/8 *Cos(25 *t) - 7/2 *Cos(26 *t) - 5/6 *Cos(27 *t) _
- 11/10 *Cos(28 *t) + 1/2 *Cos(29 *t) - 1/5 *Cos(30 *t)
end function
function y(t)
'y = 130*sin(3*t)
y = 0 -(637 * Sin(t)) / 2 - 188 / 5 * Sin(2 * t) - 11 / 7 * Sin(3 * t) _
- 12 / 5 * Sin(4 * t) + 11 / 3 * Sin(5 * t) - 37 / 4 * Sin(6 * t) _
+ 8 / 3 * Sin(7 * t) + 65 / 6 * Sin(8 * t) - 32 / 5 * Sin(9 * t) _
- 41 / 4 * Sin(10 * t) - 38 / 3 * Sin(11 * t) - 47 / 8 * Sin(12 * t) _
+ 5 / 4 * Sin(13 * t) - 41 / 7 * Sin(14 * t) - 7 / 3 * Sin(15 * t) _
- 13 / 7 * Sin(16 * t) + 17 / 4 * Sin(17 * t) - 9 / 4 * Sin(18 * t) _
+ 8 / 9 * Sin(19 * t) + 3 / 5 * Sin(20 * t) - 2 / 5 * Sin(21 * t) _
+ 4 / 3 * Sin(22 * t) + 1 / 3 * Sin(23 * t) + 3 / 5 * Sin(24 * t) _
- 3 / 5 * Sin(25 * t) + 6 / 5 * Sin(26 * t) - 1 / 5 * Sin(27 * t) _
+ 10 / 9 * Sin(28 * t) + 1 / 3 * Sin(29 * t) - 3 / 4 * Sin(30 * t) _
- (125 * Cos(t)) / 2 - 521 / 9 * Cos(2 * t) - 359 / 3 * Cos(3 * t) _
+ 47 / 3 * Cos(4 * t) - 33 / 2 * Cos(5 * t) - 5 / 4 * Cos(6 * t) _
+ 31 / 8 * Cos(7 * t) + 9 / 10 * Cos(8 * t) - 119 / 4 * Cos(9 * t) _
- 17 / 2 * Cos(10 * t) + 22 / 3 * Cos(11 * t) + 15 / 4 * Cos(12 * t) _
- 5 / 2 * Cos(13 * t) + 19 / 6 * Cos(14 * t) + 7 / 4 * Cos(15 * t) _
+ 31 / 4 * Cos(16 * t) - Cos(17 * t) + 11 / 10 * Cos(18 * t) _
- 2 / 3 * Cos(19 * t) + 13 / 3 * Cos(20 * t) - 5 / 4 * Cos(21 * t) _
+ 2 / 3 * Cos(22 * t) + 1 / 4 * Cos(23 * t) + 5 / 6 * Cos(24 * t) _
+ 3 / 4 * Cos(26 * t) - 1 / 2 * Cos(27 * t) - 1 / 10 * Cos(28 * t) _
- 1 / 3 * Cos(29 * t) - 1 / 19 * Cos(30 * t)
end function
'conversions (logical coords to screen)
function sx(x)
'screen X. Depends on width, minX, maxX
sx = (x- minX)/(maxX-minX) * width
end function
function sy(y)
'screen Y. Depends on height, minY, maxY. Upside down.
sy = (1-(y- minY)/(maxY-minY)) * height
end function