
-----------------------------------
Tubs
Mon Mar 17, 2003 11:58 am

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?

-----------------------------------
Tony
Mon Mar 17, 2003 12:18 pm


-----------------------------------
wow dude, your graphing is WAY off... I cant see it actually... here's the correct way of graphing a line:


    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 :wink:

-----------------------------------
Tubs
Mon Mar 17, 2003 12:24 pm


-----------------------------------
hahaha you noticed that did you ;)

anyways k i will try that gimme 1 sec

-----------------------------------
Tubs
Mon Mar 17, 2003 12:27 pm


-----------------------------------
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
Mon Mar 17, 2003 12:53 pm


-----------------------------------
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.

-----------------------------------
Big_Tom
Tue Mar 18, 2003 11:59 am


-----------------------------------
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
Tue Mar 18, 2003 12:01 pm


-----------------------------------
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
Tue Mar 18, 2003 12:12 pm


-----------------------------------
actually no, the program has its own coordinate system

-----------------------------------
Asok
Tue Mar 18, 2003 12:18 pm


-----------------------------------
Nevermind what I said then ;)

-----------------------------------
Tubs
Tue Mar 18, 2003 12:28 pm


-----------------------------------
its aight, and i got it to work for you who were wondering



Graph

    for I : -midx .. midx
        Z := round (M * (I - X) + Y)

        drawfilloval (midx + I, Z + midy , 2, 2, 12)

    end for [/code]

-----------------------------------
Big_Tom
Tue Mar 18, 2003 12:56 pm


-----------------------------------
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
Tue Mar 18, 2003 12:59 pm


-----------------------------------
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
Tue Mar 18, 2003 1:32 pm


-----------------------------------
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.

-----------------------------------
Tubs
Wed Mar 19, 2003 12:51 pm


-----------------------------------
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
Wed Mar 19, 2003 1:00 pm


-----------------------------------
fontID has not been declared.

-----------------------------------
Tony
Wed Mar 19, 2003 1:05 pm


-----------------------------------
var fontID:int := Font.New("arial:14:bold")

or something like that... first is font name, then its size then you can add stuff like bold... you dont have to, just put " after the size

-----------------------------------
Tubs
Wed Mar 19, 2003 8:20 pm


-----------------------------------
ya but i have that declared for the 3d text at the start, will i have to make a new fontID var to do this?

-----------------------------------
Asok
Wed Mar 19, 2003 9:47 pm


-----------------------------------
fontID1 or if there are alot u can make it an array of int.

-----------------------------------
Tony
Wed Mar 19, 2003 10:26 pm


-----------------------------------
fonts for 3D text are decleared as an array.

you can use fontID(size) if I remember it correctly and if that particular size was decleared.

-----------------------------------
Tank
Thu Mar 20, 2003 12:07 pm


-----------------------------------
How do I fix the parabola when the equation is...

    for x : -halfx .. halfx
        y := round (M * (x - P)**2 + Q)

plz reply with your answer if you know it :)
