Using Visual C and your OpenGL configured environment write
Using Visual C++ and your OpenGL configured environment, write an application that calculates and plots the 2D parabolic trajectories for an object whose starting position is p1 = (500,400) with velocities, v = (30m/s,40 m/s),for at least 4 different planets including Earth. Plot the trajectories using different line colors and styles for values of time increments of 1 second. Plot the trajectories only up to the first negative Y value. For example, the last 3 plotted points (x,y) might be
860 174.4
890 91.9
920 -0.4
No additional points beyond the first negative value should be plotted.
Label the trajectories corresponding to the planets selected. Be sure to reference your source used for the gravity for the planets. Be sure your plot is well-organized, includes grid lines, x and y axis, x-axis and y-axis labels, and legends. Each trajectory should use a different symbol or shape or color. One possible graphic result is shown below.
700 600 500 400 300 200 Earth Mercury Venus 200 100 0 -100 -200 X Jupiter 500 1000 1500Solution
using visual c++ and openGl the application will be as follows /* Shape */ void polygon (wcPt2D *verts) { GLint k; glBegin (GL_QUADS); for (k = 0; k < 4; k++) glVertex2f(verts [k].x, verts [k].y); glEnd(); } /* Initial position */ GLint nVerts = 4; wcPt2D verts [4] = { {25.0, 75.0}, {75.0, 75.0}, {25.0, 25.0}, {75.0, 25.0} }; /* Centroid */ GLint k, xSum = 50, ySum = 50; for (k =0; k < nVerts; k++) { xSum += verts [k].x; ySum += verts [k].y; } centroidPt.x = GLfloat (xSum) / GLfloat (nVerts); centroidPt.y = GLfloat (ySum) / GLfloat (nVerts); /* Transformation parameters */ GLfloat tx = 50.0, ty = 100.0; GLfloat sx = 1.5, sy = 1.5; GLdouble theta = pi/1.5;