pouët.net

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
added on the 2014-05-29 16:59:57 by tonyrocks tonyrocks
Hot to? What a jerk.
added on the 2014-05-29 17:00:36 by tonyrocks tonyrocks
Try with Lissajous curves. They're very hot.
added on the 2014-05-29 17:34:01 by ham ham
Lissajous is pretty nice.
added on the 2014-05-29 17:40:33 by tonyrocks tonyrocks
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.
added on the 2014-05-29 18:03:43 by musk musk
how about drawing that with the Draw command:

100 DRAW 1,x,y
added on the 2014-05-29 18:45:50 by tonyrocks tonyrocks
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).
added on the 2014-05-29 20:43:32 by tomaes tomaes
(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.
added on the 2014-05-29 21:20:22 by tomaes tomaes
As always, put some heart into it!
added on the 2014-05-29 21:24:17 by Harekiet Harekiet
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)
added on the 2014-05-29 21:26:46 by tonyrocks tonyrocks
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;
added on the 2014-05-29 21:33:55 by tomaes tomaes
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
added on the 2014-05-29 21:37:26 by Harekiet Harekiet
oh! ok. cool. I'll have to check this out. You guys rock.
added on the 2014-05-29 21:45:50 by tonyrocks tonyrocks
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
added on the 2014-05-29 22:27:42 by tomaes tomaes
Good morning. Have an improved version, why not. ;)
added on the 2014-05-30 08:05:48 by tomaes tomaes
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.
added on the 2014-05-30 15:07:44 by tonyrocks tonyrocks
HA!
added on the 2014-05-30 16:08:36 by tonyrocks tonyrocks
next step is drawing from Futurama?=)
added on the 2014-06-01 16:22:45 by g0blinish g0blinish

login