
-----------------------------------
piemaster
Wed Feb 28, 2007 8:09 pm

real values with drawfilloval()
-----------------------------------
We recently started 
var x : real := 0
function fx (x : real) : real
    result ((4 * (x ** 3)) + (3 * (x ** 2)) - (2 * x) + 6) / (x + 9)
end fx
drawfillbox(0,0,maxx,maxy,black)
Draw.ThickLine(320,maxy,320,0,2,white)
Draw.ThickLine(0,200,maxx,200,2,white)
loop
x:=-3.2
drawfilloval(x,fx(x),2,2,white)
x:=x+0.1
exit when x = 3.2
end loop

as you can see, i have a function that calculates the y value for the center of the circle [which is a plot point on the graph, the x value is initially -3.2 and increases incrementally till 3.2]
the error Turing throws at me is Argument is the wrong type. I assume this means I cant use a decimal value for either coordinate in the drawfilloval. is there any way around this?


ps: I'm new here, if this post is completely out of bounds please lmk. Its not for homework, just for fun and i have valid , self-written code.
pps: I'm also new to turing, so if im going about this in a completely idiotic manner, please don't judge   :)

-----------------------------------
Clayton
Wed Feb 28, 2007 8:15 pm

Re: real values with drawfilloval()
-----------------------------------
you simply have to take the real value that you are getting and round() it to an integer. This makes sense because you can't have 1/2 a pixel right?

-----------------------------------
piemaster
Wed Feb 28, 2007 8:21 pm

RE:real values with drawfilloval()
-----------------------------------
but if i do that, wont the graph be inaccurate? i understand you can have half a pixel, but then is the problem given flawed?

thanks for the help btw :)

//edit:

if i edit the code to look something like this:


loop
x:=-3.2
drawfilloval(round(x),round(fx(x)),2,2,white)
x:=x+.1
exit when x = 3.2
end loop

the output kaboomerates itself.
