Functions graph

fuv
2010-01-30
2013-05-02
  • fuv
    fuv
    2010-01-30

    Hello,
    I have to make program which can draw a function grap. I mean I have field where I can write function(I mean this standard one - nothing advanced) and somewhere a graph of this function appear. Is it possible by wxMathPlot?

    Grtz
    Fuv

     
  • cdron77
    cdron77
    2010-01-31

    Well, it depends on what do you mean exactly: if you mean that you can create an application that does this, the answer is yes. You have to implement the function parser, and then a plot layer which draws it. On the other hand, if you mean to ask if wxMathPlot already does this, the answer is no: it's just a library for plotting data, but the task of generating data is left to the programmer. Other tools like KmPlot ( http://edu.kde.org/kmplot/ ), or math tools like octave and scilab, already accomplish to this task very well.

     
  • fuv
    fuv
    2010-01-31

    Ok, I will try that kmplot as well.

    I am thinking about using wxMathPlot. You said that I need to generate data to it. Can I made it by function parser? For example : http://warp.povusers.org/FunctionParser/. If so, how?

    Grtz

     
  • cdron77
    cdron77
    2010-02-01

    Well, I never used that library, but looking quickly at the documentation, I believe that the easiest way to use it is to implement a class inheriting from mpFX, then calling the Eval() function of the parser inside the GetY() method.

    Good Luck!
    CD-RON77

     
  • JuPe
    JuPe
    2010-02-01

    Hi,

    I 've done some similar functions to gpPanel ( library. It use wxMathPlot for plotting.. Parser I made myself. It is a lot of simpler than those discussed in this implementation, but it does list the most common mathematical operators (-+/*sin/cos/… also closing phrases "4*(4-4)") . Parser has a few bug, which I have not had time to repair, but mostly it works. Print library environment is a bit more complicated, but if you examine a little, you can find tips for your implementation.

    -JuPe

     
  • fuv
    fuv
    2010-02-01

    Could I use your parser? I have really little time… Could you show/send me one?

    Grtz

     
  • JuPe
    JuPe
    2010-02-01

    you can use, but I take no responsibility for errors in calculation:).
    If you find errors in calculating the results, so tell them where the patterns revealed.

    parser:
    http://code.google.com/p/gppanel/source/browse/trunk/gpPanel/math/gpFormula.h

    used for something like this:
    #include "gpFormula.h"    //all needed is in here.
    double x, y;
    gpFormula xform( "2*Y" ); //formula to parse

    for(y=1;y<100;y++)
    {
      xform.AddVariable("Y", y); //insert Y variable
      x = xform; //     '=' -operator calculate the formula…
    }

     
  • fuv
    fuv
    2010-02-01

    So you say, for example how to convert simple function y=sin(2x)?