- #1
Badboy
- 6
- 0
hey. i want to graph a projectile motion. i got the code of a sine wave but the x and y axis' are in the opposite sides. i want the curve to look like a projectile with the curve facing down. thanx. here's my code
#include <iostream.h>
#include <iomanip.h>
#include <math.h>
#include <cstdlib>
void main()
{
const float PI = 3.1416;
const int STEPS = 16;
const int SIZE = 15;
const char STAR = '*';
const char BLANK = ' ';
int step;
float angle;
int indent;
char again = 'n';
do
{
system("cls");
cout << " SINEWAVE SAMPLE PROGRAM\n\n";
cin.get();
angle = 0;
indent = 0;
for (step=0; step<=STEPS; step++)
{
angle = (PI) * step / STEPS;
indent = 5.5 + SIZE + SIZE * sin(angle);
cout << setiosflags(ios::showpoint|ios::fixed)
<<setprecision(2)
<< setw(6) << angle/PI << "pi";
for (int i = 1; i <= indent; i++)
cout << BLANK;
cout << STAR << "\n";
}
cout << "Angle\n(radians)\n\n";
cin.get();
system("cls");
cout << "Do you want to run the program again (y/n) ? ";
cin >> again;
}
while ((again == 'y') || (again == 'Y'));
return;
}
#include <iostream.h>
#include <iomanip.h>
#include <math.h>
#include <cstdlib>
void main()
{
const float PI = 3.1416;
const int STEPS = 16;
const int SIZE = 15;
const char STAR = '*';
const char BLANK = ' ';
int step;
float angle;
int indent;
char again = 'n';
do
{
system("cls");
cout << " SINEWAVE SAMPLE PROGRAM\n\n";
cin.get();
angle = 0;
indent = 0;
for (step=0; step<=STEPS; step++)
{
angle = (PI) * step / STEPS;
indent = 5.5 + SIZE + SIZE * sin(angle);
cout << setiosflags(ios::showpoint|ios::fixed)
<<setprecision(2)
<< setw(6) << angle/PI << "pi";
for (int i = 1; i <= indent; i++)
cout << BLANK;
cout << STAR << "\n";
}
cout << "Angle\n(radians)\n\n";
cin.get();
system("cls");
cout << "Do you want to run the program again (y/n) ? ";
cin >> again;
}
while ((again == 'y') || (again == 'Y'));
return;
}