Hot to plot a heart curve in Commodore 128 BASIC
category: code [glöplog]
Ok, so I'm working on something wild, and with that I'm trying to generate a Heart Curve using this formula, but only using Commodore Basic 7 Draw command to plot points... Not draw to.
The input is this: x^2+(y-(x^2)^(1/3))^2 = 1 and can be seen here:
http://www.wolframalpha.com/input/?i=x%5E2%2B(y-(x%5E2)%5E(1/3))%5E2+%3D+1
thanks for the help. rock on
The input is this: x^2+(y-(x^2)^(1/3))^2 = 1 and can be seen here:
http://www.wolframalpha.com/input/?i=x%5E2%2B(y-(x%5E2)%5E(1/3))%5E2+%3D+1
thanks for the help. rock on
Hot to? What a jerk.
Try with Lissajous curves. They're very hot.
Lissajous is pretty nice.
I can explan how that heart curve works.
1. Circle (x^2) + (y^2) = 1
2. Shift down the middle part with a different function, in your example that (x^2)^(1/3)
Done!!!
So in a less mathematical way: plot a circle and shift down some pixels in the middle and BAM!!! <3
How to do it with Lissajous?, well you can't get sharp edges, however you can mirror the curve on the Y axis.
1. Circle (x^2) + (y^2) = 1
2. Shift down the middle part with a different function, in your example that (x^2)^(1/3)
Done!!!
So in a less mathematical way: plot a circle and shift down some pixels in the middle and BAM!!! <3
How to do it with Lissajous?, well you can't get sharp edges, however you can mirror the curve on the Y axis.
how about drawing that with the Draw command:
100 DRAW 1,x,y
100 DRAW 1,x,y
Pretty much a wolfram alpha standard use case: x^2+(y-sqrt(x^2))^2=1; Solve for y and plot away. Don't even have to use pokes on a c128 (it's Basic 7.0 after all).
(and no, I didn't read the OP ;P What is even the question? How to use for/next? Anyway, Here's a general guide on CBM Basic 7 programming; Sections 3-5 & 17 should answer all your questions.
As always, put some heart into it!
tomaes, thanks for responding. I guess maybe I'm just too dumb to figure out how to turn x^2+(y-sqrt(x^2))^2=1 into something I can work with in Basic 7. Like, how to assign those variables, and stuff. Obviously I can't do this:
5 graphics 3,1
10 for X=1 to 320
20 something = x^2+(y-sqrt(x^2))^2=1
30 DRAW 1,x,y
40 next
I'm soo lame. (i didn't say n00b because I'm old... we call eachother lamerz)
5 graphics 3,1
10 for X=1 to 320
20 something = x^2+(y-sqrt(x^2))^2=1
30 DRAW 1,x,y
40 next
I'm soo lame. (i didn't say n00b because I'm old... we call eachother lamerz)
Look at the wolfram alpha link; The equation is already solved for y; then you just have y=... and you have normal Cartesian coordinates you can draw (1,x,y); You probably need a -x to +x loop and recalc that into screen space (+a times width), before you draw it;
http://www.wolframalpha.com/input/?i=solve++x%5E2%2B%28y-sqrt%28x%5E2%29%29%5E2%3D1+for+y
So 2 y's for every x, you could probably do some mirroring on both sides or whatever
So 2 y's for every x, you could probably do some mirroring on both sides or whatever
oh! ok. cool. I'll have to check this out. You guys rock.
Code:
5 graphic 1,1
10 forx=-1to1step.01
20 q = sqr(1-x*x)
30 y0 = sqr(x*x) - q
40 y1 = sqr(x*x) + q
44 xa = int((x+1)*160)
45 ya = int((y0+1)*100)
48 yb = int((y1-1)*100)
50 draw 1,xa,200-ya
52 draw 1,xa,40-yb
58 print yb
60 next
I must be super-bored or something. :D
Good morning. Have an improved version, why not. ;)
oh my...this is crazy. I go out to Belvederes in Pittsburgh for 80's music night...I get back home at 2:00 am, and THIS IS WHAT I GET?!
Awesome. Thanks tomaes. Feelin Dank.
Awesome. Thanks tomaes. Feelin Dank.
next:
Hot random My Little Pony curve: http://www.wolframalpha.com/input/?i=random%20my%20little%20pony%20curve
Hot random My Little Pony curve: http://www.wolframalpha.com/input/?i=random%20my%20little%20pony%20curve
HA!
next step is drawing from Futurama?=)