| | |
Max Height formula
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 43
Reputation:
Solved Threads: 1
I cant figure out how to make a function that correctly solves the max height of a parabola
I know height = distance * tan(angle) - (gravity * distance^2) /2 *( speed * cos(angle))^2
I try to put this in and I get like 1.2 trillion
I think im doing it right....
anyone mind helping me figure this out?
Distance = 3831.57
Angle = 35
Gravity = 9.81
Speed = 200
after inputing these in the the formula the anwser is suppose to be like 670 but I dont know how to do it let alone put it in c++
I know height = distance * tan(angle) - (gravity * distance^2) /2 *( speed * cos(angle))^2
I try to put this in and I get like 1.2 trillion
I think im doing it right....
anyone mind helping me figure this out?
Distance = 3831.57
Angle = 35
Gravity = 9.81
Speed = 200
after inputing these in the the formula the anwser is suppose to be like 670 but I dont know how to do it let alone put it in c++
0
#2 29 Days Ago
•
•
•
•
I know height = distance * tan(angle) - (gravity * distance^2) /2 *( speed * cos(angle))^2
height = (distance*(tan(angle)))-((gravity*(distance*distance))/(2*((speed*(cos(angle)))*(speed*(cos(angle))))))
Better to use too many parentheses then too few
0
#3 29 Days Ago
C++ Syntax (Toggle Plain Text)
#include<cmath> height = (distance * tan(angle)) - (gravity * pow(distance, 2)) /2 * pow(speed * cos(angle), 2);
Last edited by Clinton Portis; 29 Days Ago at 3:06 pm.
0
#7 29 Days Ago
•
•
•
•
That is the formula I was using Clinton Portis and it still came out to 1.7 x 10 to the 13th
This is what you posted:
C++ Syntax (Toggle Plain Text)
I know height = distance * tan(angle) - (gravity * distance^2) /2 *( speed * cos(angle))^2
which is not the same as this:
C++ Syntax (Toggle Plain Text)
#include<cmath> height = (distance * tan(angle)) - (gravity * pow(distance, 2)) /2 * pow(speed * cos(angle), 2);
Last edited by Clinton Portis; 29 Days Ago at 3:10 pm.
•
•
Join Date: Oct 2009
Posts: 43
Reputation:
Solved Threads: 1
0
#9 29 Days Ago
Well this is what I have... It compiles and everything just somthing is funky when trying to find out the max height 

C++ Syntax (Toggle Plain Text)
#include <iostream> #include <cmath> using namespace std; // This program is to calculate the trajectories of projectiles and how the initial speed and // angle from the horizontal affect the distance the projectile will travel on different planets // and satellites. // //******************************************************************** // //Example interaction with the user: //Trajectory Plotter! //Enter a speed of launch (mps): 200 //Enter the angle of launch (in degrees): 35 //Speed = 200.00 mps, Angle = 35.00 degrees = 0.61 radians //Distance travelled on Earth = 3831.57 m, max height = 670.72 m //Distance travelled on Mars = 9970.21 m, max height = 1745.30 m //Distance travelled on the Moon = 23202.29 m, max height = 4061.60 m //Maximum distance traveled = 23202.29 //Maximum height reached = 4061.60 //For Earth, the 5 points of the parabola would be: // x0, y0 (0.00, 0.00) // x1, y1 (957.89, 503.04) // x2, y2 (1915.79, 670.72) // x3, y3 (2873.68, 503.04) // x4, y4 (3831.57, 0.00) // //******************************************************************** double angtorad (double angle, double pi); double distance_earth (double angle, int mps, double earth_gravity); double distance_moon (double angle, int mps, double moon_gravity); double distance_mars (double angle, int mps, double mars_gravity); double height_earth (double radian, int mps, double earth_gravity, double earthx); double height_mars (double radian, int mps, double mars_gravity, double marsx); double height_moon (double radian, int mps, double moon_gravity, double moonx); int main () { int mps; double angle; cout << " *** Program 3 Planetary Trajectory Simulator *** " << endl; cout << endl; cout << " Enter the speed of launch (mps) "; cin >> mps; cout << " Enter the angle of launch (degrees) " ; cin >> angle; cout << endl; double pi = 3.1415927; double radian = pi * ( angle / 180); double earth_gravity = 9.81; double moon_gravity = 1.62; double mars_gravity = 3.69; double earthx = distance_earth (angtorad(angle,pi),mps,earth_gravity); double marsx = distance_mars (angtorad(angle,pi),mps,mars_gravity); double moonx = distance_moon (angtorad(angle,pi),mps,moon_gravity); cout << " You have entered " << mps << " mps for the speed and " << angle << " degrees for the angle." << endl << endl; cout << " " << angle << " degrees is equal to " << angtorad(angle, pi) << " radian(s)." << endl << endl << endl; cout << " The distance traveled on Earth = " << distance_earth (angtorad(angle,pi),mps,earth_gravity) << " meters --"; cout << " Max Height = " << height_earth (angtorad(angle,pi), mps, earth_gravity, earthx) << endl; cout << " The distance traveled on Mars = " << distance_mars (angtorad(angle,pi),mps,mars_gravity) << " meters -- "; cout << " Max Height = " << height_mars (angtorad(angle,pi), mps, mars_gravity, marsx) << endl; cout << " The distance traveled on The Moon = " << distance_moon (angtorad(angle,pi),mps,moon_gravity)<< " meters "; cout << " Max Height = " << height_moon (angtorad(angle,pi), mps, moon_gravity, moonx) << endl; return 0; } double angtorad (double angle, double pi) { double radian; radian = pi * (angle / 180); return radian; } double distance_earth (double angle, int mps, double earth_gravity) { double earth_distance; earth_distance = sin(angle + angle)*(mps*mps) / earth_gravity; return earth_distance; } double distance_moon (double angle, int mps, double moon_gravity) { double moon_distance; moon_distance = sin(angle + angle)*(mps*mps) / moon_gravity; return moon_distance; } double distance_mars (double angle, int mps, double mars_gravity) { double mars_distance; mars_distance = sin(angle + angle)*(mps*mps) / mars_gravity; return mars_distance; } double height_earth (double radian, int mps, double earth_gravity, double earthx) { double max_height_earth; max_height_earth = (earthx*(tan(radian)))-((earth_gravity*(earthx*earthx)) / (2*((mps*(cos(radian)))*(mps*(cos(radian)))))); return max_height_earth; } double height_mars (double radian, int mps, double mars_gravity, double marsx) { double max_height_mars; max_height_mars = (marsx*(tan(radian)))-((mars_gravity*(marsx*marsx)) / (2*((mps*(cos(radian)))*(mps*(cos(radian)))))); return max_height_mars; } double height_moon (double radian, int mps, double moon_gravity, double moonx) { double max_height_moon; max_height_moon = (moonx*(tan(radian)))-((moon_gravity*(moonx*moonx)) / (2*((mps*(cos(radian)))*(mps*(cos(radian)))))); return max_height_moon;
![]() |
Similar Threads
- 4 short programs (Java)
- Table height (HTML and CSS)
- min height (HTML and CSS)
- how to maximize table cell height (JavaScript / DHTML / AJAX)
- How do I add a vertical scroll bar to a form? (Visual Basic 4 / 5 / 6)
- finding height of a binary search tree without using recursion (Java)
- How do i load a image on the same page ? (Site Layout and Usability)
- urgent help!!! (C++)
- A question on an error in a SpringLayout example program (Java)
- binary trees (C)
Other Threads in the C++ Forum
- Previous Thread: (Beginner) How can make it slower?
- Next Thread: Disabling fullscreen using GLUT
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete desktop developer directshow dll download dynamic encryption error file forms fstream function functions game generator getline givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory news node number output parameter pointer problem program programming project proxy python random read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





