Computer Science Canada Drawing a Curved line |
Author: | shodai [ Tue Oct 04, 2016 3:10 pm ] |
Post subject: | Drawing a Curved line |
I am trying to create a curved line that looks like what you would see in a graph showing exponential growth. I have tried a couple of approaches but the results are not what I am looking for. I think the issue is simply the formula. Does anyone know what formula I would use for x and y coordinates to make such a line? This is my best result so far. var x : int var y : int x := 200 y := 200 for i : 1 .. 200 Draw.Dot (x, y, green) if i < 100 then x := x + 1 if y mod 2 = 0 then y := y + 1 end if else y := y + 1 if x mod 2 = 0 then x := x + 1 end if end if end for |
Author: | DemonWasp [ Thu Oct 06, 2016 9:28 am ] |
Post subject: | RE:Drawing a Curved line |
If you want to show exponential growth, you should compute exponential growth. See http://compsci.ca/holtsoft/doc/exp.html , and remember that exponential functions grow very quickly. Consider using Draw.Line from the previous point to the current point, so that you can see it when the function goes off the screen. |