Page 1 of 2
The all mighty graph and the power of math
Posted: Fri Sep 30, 2005 11:33 am
by Charles256
Okay..I've seen some utilities that graph like pie charts and stuff but are there programs out there that graph complex mathematrical functions? If no, would anyone be interested in such a program? I'm finely delving into the finer points of Cal. 3 and we have a lot of weird looking 3d functions and my teacher is praising this program that graphs them so I figured it might be fun to make something simliar or better in PHP and release it as freeware just to spite said company.

Posted: Fri Sep 30, 2005 11:48 am
by feyd
there's always a market for graphing, especially more complex maths.. I'd think it'd be very appreciated among the community

Posted: Fri Sep 30, 2005 11:50 am
by Charles256
Okay. Now to start the logic fo such a thing. Considering I've never generated a random image with PHP this aughta rock:-D But since it doesn't exist all ready in PHP and open source I see no reason not too give it the old college try. ( all the more relevant seeing as I am in college.

)
Posted: Fri Sep 30, 2005 11:59 am
by feyd
One thing I'll recommend, have an accuracy mode switch.. There are fast approximations for a lot of math functions such as finding the distance between two arbitrary 2D coords being the longest dimension plus half the shortest.. (at least that's what I remember

)
Posted: Fri Sep 30, 2005 12:47 pm
by Charles256
I was thinknig about it as I ate my double quarter pounder and I think I'm going to extend it to solve most math equations as well. With a little tweaking I should be able to switch it to solve all equations. for example when integrating and differentiating (used to come up with speed formulas and such) you occasionally run into a few rare examples where the rules don't apply and you have to use a slightly altered sense of the rules to get it to work but what are if statements for?:) Either way, as for graphing the 3d functions since I am working with 2d objects I was thinking have a button to change perspective, I.E. top/left/right/bottom and then your normal head on. If any of you have ever drawn a 3d graph then you kinda get a feel for what I'm saying. is there a function that draws 3d objects in PHP or would I have to start from scratch on that?If so I've been thinking about how to go about that and I see the possibilities forming..
: stops to breathe :
Posted: Fri Sep 30, 2005 1:42 pm
by Charles256
yeah if you have any things you'd like to see in a math type function/page let me kniow because here is my first attempt to contribute to the community at large:)
Posted: Fri Sep 30, 2005 2:55 pm
by pickle
You could probably use JPGraph to generate the graphs. That would cut down your work load to just calculate the data points.
PHP has no powerful math library, but this link says it provides some tips for creating math libraries in PHP:
http://www.opensourcetutorials.com/tuto ... page1.html
Posted: Fri Sep 30, 2005 3:03 pm
by feyd
odd.. I always found creating my own graphics engines quite fun on their own..

Posted: Fri Sep 30, 2005 3:09 pm
by Charles256
i don't really like the way that displays graphs to be honest :-/ doesn't do a good job of showing x,y, and z (in all fairness I might have just missed the relevant screen shot ) . I want users to be able to look at the graph and be able to tell due to ticking on the graph (tick for 1,tick for 2, you know:) ) that the graph is actually what they expected and is 100% accurate rather than a close enough. As for the math libraries, that's all ready what I had in mind by using classes and what not. Who knows if I do good enough maybe my "math library" will see some distribution. Though this will take mucho time but that's okay, learning process is worth it.

The only thing I'm not quite sure how I'll do is create lines, points is one thing but lines? oh well.I might just have the calculations run through close to every number in the range they provide so even if it isn't a solid line any dummy can tell what's going on:-D Changing the perspetive is going to be the annoying part I do believe.
Posted: Fri Sep 30, 2005 4:09 pm
by feyd
once you understand the quarternions/matrices involved in mapping 3D into 2D perspective, it's actually not all that hard..
Posted: Fri Sep 30, 2005 6:16 pm
by Maugrim_The_Reaper
Sounds like an interesting project. I'm currently 60% though redesigning a legacy PHP game (it's going very fast since I finished all my planning, class outlines and MVC work). One thing I keep running into are displaying 3D graphs, statistics, 3D map coordinates and such within 2D images, It's a problem I'm looking to tackle in the near future.
Sounds like there may be some overlap with your own ideas - be good to hear from you, I may have a few spare fingers to lend you...

Posted: Fri Sep 30, 2005 6:20 pm
by Charles256
feel free to drop me a line, i have about ten million ways to contact me through my profile:)
Posted: Sat Oct 01, 2005 4:36 am
by pilau
Maugrim_The_Reaper wrote: [...] I finished my [...] MVC work.
@Maugrim: What's MVC?
@Charles: Well, it sounds very interesting and professional. Good luck! (I just set my ambitions a tad higher

)
Posted: Sat Oct 01, 2005 4:59 am
by n00b Saibot
pilau wrote:@Maugrim: What's MVC?
Multi-View Controller
Posted: Sat Oct 01, 2005 6:03 am
by Maugrim_The_Reaper
MODEL-View-Controller...
It's a pattern for dividing web applications into three layers (well, there's a fourth I use - Data Access). Each layer has responsibility for its own tasks. Taking an example - let's take a game with a character. I want to request the application to display the character's data. Typicaly I would issue a request ( game.php?action=character.display)
The controller (a FrontController, well, what I CALL a FrontController) parse the action. It includes the Character>Display Command (a class in the Model Layer) upon which the FC calls its execute() method. In this case the Command would make a few calls to the Database by calling methods in the Data Access Layer. The FC then grabs a View (e.g. a method for parsing a Smarty template, and assigning values to template variables the Command requested though the Data Access Layer) and sends the output to browser via the View's render() method.
I know it sounds all complex - but it's quite a useful pattern, that in turn uses other patterns (FrontController, Command, etc.) You separate out responsibility, allow layers to delegate to other layers (when a task to be performed is another layer's responsibility) and it's pretty easy to maintain.
It's nicest benefit is re-usability - I develop 3 games, so having such a re-useable framework is a huge time saver. Also let's me do a few other nifty things like centralising responsibilty for input filtering, etc to the FC.
Gotta stop rambling now...
http://java.sun.com/blueprints/guidelin ... arch2.html
http://en.wikipedia.org/wiki/Model_view_controller
http://msdn.microsoft.com/library/defau ... DesMVC.asp
You really should research design patterns - you will not regret it...