----------------------------------- Fazonica Tue May 04, 2004 2:04 pm Drawing Lines (on a cartesian plane-type-thing)? ----------------------------------- Hey!! Ok, for homework, we had to write a program. It's just that I can't figure out where to start!! All I've gotten so far is the user input part, but I can't get past that because I just don't know how to do the rest of the question! Here's the question: "Create a program which will draw a line of "o"'s on a cartesian plane The centre of the screen should be the point (0,0). Allow the user to enter the values for m and b and the beginning and end points for x. Note, all values must be between -10 and +10." I hope someone can help!! Even just a vague idea of what to do is good enough!! Thanks!! ----------------------------------- Paul Tue May 04, 2004 2:10 pm ----------------------------------- make the screen into a grid of 10 by 10, since the center of the screen is on 0,0 the bottom left corner, then all things drawn would be in the I quadrant wouldn't it? Map the x and y line positions into 2 arrays, then when the user enters say b=(8,4) then u get the x position of the line 8 and y position of line 4, and where they meet would be a point on ur line. The using the slope find 2 other points on ur grid and find coordinates using array, then draw the line. ----------------------------------- Fazonica Tue May 04, 2004 2:14 pm ----------------------------------- Thanks!! I'll try that. But how would you change the grid size? We haven't really learnt how to do that yet. :? We just started Loops last week... (I'm doing the Grade 10 course.) ----------------------------------- Cervantes Tue May 04, 2004 2:23 pm ----------------------------------- uh, paul, you misread the part where the question said, " The centre of the screen should be the point (0,0)." anywho, drawing stuff with text sucks. but if you have to, you have to. To make drawing text more like drawing graphics, use the locatexy command. after that, its just math. ----------------------------------- Paul Tue May 04, 2004 2:23 pm ----------------------------------- OOOPS! important, i just realized something, when it asks u for 0,0 , its not the pixel position on the screen! it is making 0,0 the center of the screen. 0,0 as in coordinates on grid. That makes things more complicated. Now u need to draw the grid and put the x and y values in the arrays while paying attention to the negative and positive values, it would work the same way though. Do u need a user input for grid size? if not, just set ur own gridsize, like the largest space in between lines allowing for 10 up and 10 across on the screen. If not, just make the user enter gridsize, like the spacing between lines. Then set up ur array according to that. or do u mean how many lines in the grid? [edit] yes I realize cervantes, I was busy doing this big post. ----------------------------------- Fazonica Tue May 04, 2004 2:30 pm ----------------------------------- locatexy? array? :? sorry, I'm pretty confused. I know how to do a regular locate command, if that's what you're talking about...? Maybe it would help mentioning that I only started learning this like, 2 or 3 months ago?? I don't know how to draw a grid (well I made my own pathetic attempt). Does Turing have it's own "draw grid" command?? Hmm...maybe I should check that... Ok, this might totally suck, but hey, what can I do? Here's what I've got so far (keep in mind that I only got this yesterday, and my teacher wasn't at school today, so I couldn't really get help): % declare variables var MI, BI, X1I, Y1I, X2I, Y2I:int var NumI:int:=0 % input put " ":20, "+ The Graphing Calculator +" put skip put "In order for your line to be graphed, you must enter the following: " put "the slope (m), the y-intercept (b), as well as the beginning, and " put "end points for x. The values must be between -10 and +10." loop put skip, "Slope of line: ".. get MI exit when MI >= -10 and MI = -10 and BI = -10 and X1I = -10 and Y1I = -10 and X2I = -10 and Y2I