Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Graphing calculator
Author Message
Tubs

Posted: Mon Mar 17, 2003 11:58 am   Post subject: Graphing calculator

alright this graphing calculator works for declaring a point, it puts it whereever i say. BUT whenever i put a slope it draws multiple dots... (and i know it is possible to work cause my friend got it)

whats wrong?

graphing calc.t
Description:
 graphing calc

Filename:  graphing calc.t
Filesize:  6.62 KB

Tony

Posted: Mon Mar 17, 2003 12:18 pm   Post subject: (No subject)

wow dude, your graphing is WAY off... I cant see it actually... here's the correct way of graphing a line:

 code: Graph     for I : -midx .. midx         Y := round (M * I) + midy         drawfilloval(midx + I, Y, 2,2,white)     end for

replace your procedure with that. To get the Y value, you just multiply X (which is counter, so its I) by slope (M) and add midy to bring the graph up so it runs through the middle.

instead of drawing a bunch of dots, just draw a small circle. Adding midx to the X value to bring it to the right so it runs through the middle. (You gotta account for those negative areas of the graph)

I'm glad someone found text effects tutorial useful
Tony's programming blog. DWITE - a programming contest.
Tubs

Posted: Mon Mar 17, 2003 12:24 pm   Post subject: (No subject)

hahaha you noticed that did you

anyways k i will try that gimme 1 sec
Tubs

Posted: Mon Mar 17, 2003 12:27 pm   Post subject: (No subject)

alright it makes the line, but its still all made of dots. how do i make it connected if thats possible? well i know its possible but im really tired lol

AND it messes up my graphing thing. ex, 10 x value and 10 y doesnt go up 1 square
Tony

Posted: Mon Mar 17, 2003 12:53 pm   Post subject: (No subject)

to make dots connected, you ether

a) have to draw more dots. Such as instead of looping 1,2,3 try looping 1.5,2,2.5,3, etc.

you can use only integers in forloop, so use a normal loop instead. OR

b) draw your graph using lines. Such as instead of drawing a dot, draw a line from previous dot to current dot. You'd have to keep track of the last dot drawn.
Tony's programming blog. DWITE - a programming contest.
Big_Tom

Posted: Tue Mar 18, 2003 11:59 am   Post subject: (No subject)

yes i also need help with this project. I can't get the line to graph correctly i did the same line thing that you told tubs and i still can not get it to work correctly. This slope is correct but the cordinate values are wrong and i dont know how to fix it.
Asok

Posted: Tue Mar 18, 2003 12:01 pm   Post subject: (No subject)

this is because turing coordinates work differently then graphing coordinates. in graphing the orgin (0,0) is in the center. in turing the origin is in the bottom left corner. This is probably why your coordinates are off.
Tubs

Posted: Tue Mar 18, 2003 12:12 pm   Post subject: (No subject)

actually no, the program has its own coordinate system

Asok

Posted: Tue Mar 18, 2003 12:18 pm   Post subject: (No subject)

Nevermind what I said then
Tubs

Posted: Tue Mar 18, 2003 12:28 pm   Post subject: (No subject)

its aight, and i got it to work for you who were wondering

 code: Graph     for I : -midx .. midx         Z := round (M * (I - X) + Y)         drawfilloval (midx + I, Z + midy , 2, 2, 12)     end for
[/code]
Big_Tom

Posted: Tue Mar 18, 2003 12:56 pm   Post subject: (No subject)

I want to know how to make the line an actual line not just composed of ovals. It would clean it up a little bit more.
Tubs

Posted: Tue Mar 18, 2003 12:59 pm   Post subject: (No subject)

ya that would be nice lol but...

i need to know how to declare an array, then use it in a for statement. its for putting coordinates across the graph. ex, array 1..10 is -50 .. 50 then i use the for statement to put them on the screen by a certain amount
Tony

Posted: Tue Mar 18, 2003 1:32 pm   Post subject: (No subject)

to draw a line, you find start point on -midx and end point on midx then you draw a line between them. The only difference is that the line would be 1 pixel wide, not 4.

as for arrays - http://www.compsci.ca/bbs/viewtopic.php?t=366

with explanations and examples.
Tony's programming blog. DWITE - a programming contest.
Tubs

Posted: Wed Mar 19, 2003 12:51 pm   Post subject: (No subject)

for I : 0 .. maxx by 10
for J : -50 .. 50 by 10

Draw.Text (J, I, midy, fontID, white)

end for
end for

this is supposed to draw -50 .. 50 at midy, why doesnt it work? all the vars are declared *i think* can you put the vars and the correct draw command please?
Asok

Posted: Wed Mar 19, 2003 1:00 pm   Post subject: (No subject)

fontID has not been declared.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 2  [ 20 Posts ]
Goto page 1, 2  Next
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: