PDA

Click to See Complete Forum and Search --> : Graph generator



_omAr_1984
06-28-2002, 12:53 AM
hello again..
im thinking of creating this project were u can have an x-y grpah depending on the formula u enter...
iv seen some graph generators but they all consist of buttons that are already set to create the graph:
eg tanx,sinx.....
i want the user to be able to enter the formula and then the prog. would substitue each variable with numbers starting with 0 etc... and then small dots are attached depending on the domain and range.
anyone got any ideas?
i have no prob. working on dis with others....i guess the hardest part will be taking the formula and breaking it down
im good at string manipulations though

thats all!!

_omAr_1984
07-07-2002, 10:34 PM
ahhhh i guess u ppl r too lazy for projects these days,
and im becomming lazy too!!!
im almost half way through the projects and wht iv done is take wtvr input and parse it into two arrays
eg:
input = -6+7*2x/x
array1 = [-6,7,x1array,x2array]
array2 = [+,*/]
x1array = [0,2,4,6,etc]
and iv also created a function to take these two arrays and compute the result(precedence of operators also considered)
i still have two things to do which are to:
.use paranthesis to indicate where i the first calculation will take place
.calulate for x and the other values

if anyone want sot help out reply
thx

_omAr_1984
07-09-2002, 03:26 AM
here is wht iv done in dis project so far:
http://omar_1984.tripod.com/cgi-bin/graph_gen.swf

im gonna fix the zooming problem, but i need someone to help me out at adding sin,cos,tan,and the paranthesis.
im gonna work on the squaring isssue these days.
wana help reply

_omAr_1984
07-09-2002, 03:59 AM
try dis link:
http://omar_1984.tripod.com/index.html/graph_gen.swf

_omAr_1984
07-09-2002, 04:01 AM
just paste the link in ur address bar and try

ericlin
07-14-2002, 11:49 AM
I did one in Flash 5.

It is complex.

http://www.flashkit.com/movies/Scripting/Maths/Equation-Eric_Lin-6313/index.shtml

If you like to see some explanation how I did it, here is:

http://dr_ericlin.tripod.com/math/parserNote.html

_omAr_1984
07-14-2002, 02:34 PM
hey man,
i have seen ur project from before and its really nice, good job there.
Im still working on my project and im now working on the "(" and ")".
i worked out a parse function which would store the numbers and x's in an array and the operators in another.
i just wantur help in scaling the graph.
for now im just multiplying/dividing the dots to get an effect of a zoom but that does change the graph itself.
can u plz tell me how i can zoom in and out?
thats all
thx

ericlin
07-14-2002, 07:55 PM
I would like to preserve that array data and make my zoom calculation in the procedure of "attach dots";

Instead of doing
constants[0][r] = constants[0][r] * what;
I would do
_root.bound["dot" + xAxis]._y = -constants[0][xAxis]*what;
Thus you can move or zoom y, you can also zoom or move the x; and you can replot the graph easier when the zoom button is clicked.

When I did the graph-plotting thing, I had got a problem. When user enter an equation of "y=x+3333" and click "go"; User gets nothing on the screen.(the y are very large). We can not expect user would click zoom-out to find the graph. So I need to do more jobs. In addition to "zoom", I also did "shift" to move the coordinate system to show the graph.

The other thing is the problem of x; if you want to try to plot somthing like y=cos(x); It would not be good by plotting x=0,1,2,3,4,5 etc.

_omAr_1984
07-16-2002, 01:58 AM
hey again man.
thx for the tip on the zooming thing, i really dont know why i created all that zoom function when it was that easy to do!!
anyways im still working on the project and i also had the same problem u mentioned in the last thread which is the y=x+333 issue. i can c that u have solved half the problem since ur graphs such as:
x^2 and 1/x appear good enough in the default zoom
while when i use my prog the user must zoom to get a good graph for that!
i tried using several methods to ged a better zoom such as :
if u have y = x
x = 0,1,2,3,4,5...
y = 0,1,2,3,4,5...
i tried doing this:
x = 0,1,2,3,4,5...
y = .5,1,1.5,2,2.5... (zoom in)
or
y = 0,2,4,6,8.... (zoom out)
i guess that the trig functions and the other graphing stuff are not that serious compared to the zoom issue.
o and i guess that u can easily move the graph left and right by just moving the,in my case, _root.bound MC

ericlin
07-16-2002, 04:49 AM
before plot the graph, I will go through that array once to get the max of y and min of y;

Then plot the min of y at the botton limit and max of y at the top limit. Then scale (zoom in or zoom out) according to (max-min). Then user can see the graph well fit in the bound.

_omAr_1984
07-16-2002, 11:24 PM
wassup again,
im working on the paranthesis thing right now and im finding some difficulties in creating a function for that.
u did check how i store all values and operators in array.
i have the precedence function which will do all the work for me.
i want it called with wtvr is between "(" and ")" passed as arguments. the prob is that i did do all that but i cant think of a way to take wtvr is passed and reset it in the main array.
eg:
input = (3+5)/2
constants = [3,5,2]
operators = ["(","+",")","/"]
i did the function calling part: _precedence(3+5
but i cant figure out how i can reset constants to be :
[8,2]!
wht if i have 1*(3+2)*9?
how can i make it [1,5,9]??
plz help me figure out how to do that.

ericlin
07-17-2002, 05:39 AM
For input (3+5)/2
I make it constans=["3+5",2];
and operators=["/"];

When any element in constant array is a string (not a legal number), I do parse procedures to turn that string into a legal number; "3+5" will parse into:
constant2=[3,5];
operators2=["+"];

Then I get the value of (3+5)=8; Then I feed up the first constant array by value 8, and the first constant will be
[8,2]. Operators is the same. So I get the final value of the equation.
//---------------------------------
For input=1*((3+2)*9)+5;
The first step is
constant=[1,"(3+2)*9",5];
operators=["*","+"]

The second step is parse the string: "(3+2)*9"
constant=["3+2",9];
operators=["*"];

the third step is parse the string "3+2":
constant=[3,2]
operators=["+"];

The problems are: You need to figure out a way (like stack), to complete the course. You take them apart from top-down, but then you get the value and assemble them down to top. Sometimes, the first step will contains more than one parenthesis segment.

This is the principle that I use.