Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,120 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,780 people online right now. Registration is fast and FREE... Join Now!




Graphing Projectile motion on C++

 
Reply to this topicStart new topic

Graphing Projectile motion on C++

Magic
28 Apr, 2007 - 04:19 AM
Post #1

New D.I.C Head
*

Joined: 25 Apr, 2007
Posts: 3


My Contributions
Hey. i just wanted to know how to u graph a projectile motion in C++ using sine waves. im currently using the program Microsoft Visual C++. If u could help me start or tell me how would i go about graphing a projectile, i would be really appeciate it. thanx
User is offlineProfile CardPM
+Quote Post

Mrafcho001
RE: Graphing Projectile Motion On C++
28 Apr, 2007 - 11:10 AM
Post #2

D.I.C Addict
Group Icon

Joined: 1 Nov, 2005
Posts: 753



Thanked: 5 times
Dream Kudos: 120
My Contributions
you are in way over your head here...

First you need to know basic C++, to construct the functions and algorithms required to calculate the path. Then you'd need to be familiar with an API that can support drawing to the screen, such would be Win32, DX, OpenGL, MFC and other wrappers of the Win32 API.
User is offlineProfile CardPM
+Quote Post

Magic
RE: Graphing Projectile Motion On C++
28 Apr, 2007 - 01:15 PM
Post #3

New D.I.C Head
*

Joined: 25 Apr, 2007
Posts: 3


My Contributions
i know the basics of C++ and i calculated the parth of a projectile. now i need to graph the projectile which is the part i need help in. but i am not fimilair with any of these names such as API oor the others. do u rekon u can give me a link or something that would give detailed information about these types (Win32, DX, OpenGL, MFC and other wrappers of the Win32 API). thanx for your reply.
User is offlineProfile CardPM
+Quote Post

Magic
RE: Graphing Projectile Motion On C++
30 Apr, 2007 - 02:49 AM
Post #4

New D.I.C Head
*

Joined: 25 Apr, 2007
Posts: 3


My Contributions
hi. i need help graphing the projectile motion in C++. i need to do it as a sin wave. i got this far but i think the x axis and the y axis are on the opposite sides. can someone plz tell me how to flip this sin wave so it can look like a projectile motion. here is my code. thanx

#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;
}


User is offlineProfile CardPM
+Quote Post

apolsoft
RE: Graphing Projectile Motion On C++
26 Jan, 2008 - 12:16 AM
Post #5

New D.I.C Head
*

Joined: 25 Jan, 2008
Posts: 2

QUOTE(Magic @ 30 Apr, 2007 - 03:49 AM) *

hi. i need help graphing the projectile motion in C++. i need to do it as a sin wave. i got this far but i think the x axis and the y axis are on the opposite sides. can someone plz tell me how to flip this sin wave so it can look like a projectile motion. here is my code. thanx

#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;
}

how can can simulate your code in a vertical motion? a ball from the ground..
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 09:59PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month