Hiya, I'm pretty new to C++ (using bloodshed dev).
I am trying to display the path of a projectile (tennis ball) on a graph. I can do all of the calculations and output to a text file at each point however I can't find anything on the internet to explain how to plot these points on a graph (preferably in a console window).

Thank you for your time.


12 Years
Discussion Span
Last Post by triumphost

I'm not too familiar with graphics in C++, but I can see that you need to clarify a bit more. Are you talking about generating a text graph, a image file, or displaying a window with an image in it?


Have u got all the points on the projectile?? If so then simply incude graphics.h in your program and then read through a bit of the help.. Plotting of the points will be easy.. So i dont think u ll have trouble doing.. If u have any trouble get back to the forum..


I think he means look at the .h file to see if it has any helpful descriptions.
It's highly probable that you don't have the graphics.h file, but try the #include <graphics> and see if that works.

What do you want to see? An ascii art graph? A bitmap image?
We don't know what you're looking for, so we can't really help you just yet.


to be honest I don't mind, it should look like a curved line graph (a parabola) I am open to anyway to display it.
My program currently looks like this :

#include <iostream.h>
#include <stdlib.h>
#include <fstream.h>

int main()
    //Declare Variables
    float x,y,vx,vy,t,g,ct;

          //Define variable starting values
          x=0;     //Horizontal Displacement
          y=100;   //Vertical Displacement
          vx=20;   //Horiz Velocity
          vy=0;    //Vert Velocity
          t=0;     //Time
          g=-10;   //Vertical Accelleration (Gravity)
          ct=0.1;  //Time Intervals

          ofstream data("C:/Theproj.txt");

          while (y>0) {
                  data <<"\n("<<x <<"," << y << ")";

                       x = x + ( vx * ct );
                       y = y + ( vy * ct );
                       vy = vy + ( g * ct );


          cout << "Finnished";

      return 0;

<< moderator edit: added [code][/code] tags >>

I need to firstly learn how to plot those points on a graph of some description to display to the user while the program is running ( I don't know how to do that).
Then I need to make it so the user inputs the variables I know how to do this using "cin >>" but would like to get one graph drawn first.


Me too, am new to C++ and I want to learn how to plot graphs in C++. Am planing to write codes that will help me simulate some systems in physics.
Can I find any opensource graph library?
thank you

Edited by kthouz: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.