Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw functions in C++

Tags:

c++

I would like to create charts of functions in C++. Can anyone help me in getting started ? Let's suppose I want to draw the function y=x ( it is a straight line passing through the points (0,0) (1,1) (2,2) ..... (20,20) etc. ) How could I do it ? ( If you also suggest how to draw the y & x axes it is even better ) Sorry but it is not on books ( good texts recommendations are welcome, by the way :-) C++ ) and on the net there are references mainly to game graphics. The only serious reference to my problem I was able to find is this: somewhat related question asked in this very forum ( God bless, we have stackoverflow ! )

like image 875
alwaystudent Avatar asked Apr 13 '13 06:04

alwaystudent


1 Answers

I would consider two options:

  • If you want to do everything in C++, you will probably need an external library. OpenGL is a solution, there is also Qt, which is probably easier to learn and larger (and more powerful).
  • If you can afford to output a file and read it with another program, the easiest way is to simply write an ASCII file with the coordinates of the points and plot is with Octave (free).
like image 181
Dr_Sam Avatar answered Oct 30 '22 12:10

Dr_Sam