Rocket

Hi I just recently got this program for my class, and I'm having a hard time understanding how to even start the program itself. We want to use a loop to output the values of acceleration velocity and distance for each value of t. the basis is t<=100 & distance >= 50 any help would be appreciated.




A small test rocket is being designed for use in testing a retrorocket that is intended to permit “soft” landings. The designers have derived the following equations that they believe will predict the performance of the test rocket.

(t = elapsed time in seconds)\
Acceleration = in ft/sec^2 = 4.25 - .015t^2 + (6.07t^2.751)/(9995)

Velocity = in ft/sec = 4.25t - (.015t^3)/(3) + (6.07t^3.751)/(3.751(9995))

Distance = ft = 90 + (4.25t^2)/(2) - (.015t^4)/(12) + (6.07t^4.751)/(4.751(37491))




Note: The distance equation gives the height above ground level at time t and the first term (90) is the height in feet above ground level of the launch platform that will be used.

In order to check the predicted performance, the rocket will be “flown” on a computer, using the derived equations.

Write a program to cover a maximum flight of 100 seconds. The output should be of the following form:

TIME ACCELERATION VELOCITY DISTANCE
(sec) (ft/sec2) (ft/sec) (ft)

XXX.XX XXX.XX XXX.XX XXXX.XX

(starting with 0.0 sec)

Increments of time are to be 2.0 seconds, from launch through the ascending and descending portions of the trajectory until the rocket descends to within 50 feet of ground level. Below 50 feet the time increments are to be 0.05 seconds. If the rocket impacts prior to 100 seconds, the program is to be stopped immediately after impact.





Start with implementing functions which would take time and return acceleration/velocity/distance
Then create variable to hold increment.
Create a loop like: for(double time = 0.0; time <= 100.0; time += increment)
Inside a loop do calculations, output them on screen.
Check for impact. break from the loop if needed
Check if below 50 feet. Set increment to 0.05 if so.
Add other things as needed.

Edit: reference output
  Time  Acceleration  Velocity  Distance
 (sec)     (ft/sec2)  (ft/sec)      (ft)

  0.00          4.25      0.00     90.00
  2.00          4.19      8.46     98.48
  4.00          4.04     16.71    123.70
  6.00          3.79     24.55    165.05
  8.00          3.48     31.84    221.55
 10.00          3.09     38.41    291.92
 12.00          2.66     44.17    374.65
 14.00          2.17     49.00    467.98
 16.00          1.66     52.84    570.00
 18.00          1.11     55.62    678.63
 20.00          0.55     57.29    791.72
 22.00         -0.01     57.83    907.02
 24.00         -0.58     57.23   1022.27
 26.00         -1.15     55.49   1135.17
 28.00         -1.70     52.65   1243.49
 30.00         -2.22     48.73   1345.04
 32.00         -2.71     43.79   1437.72
 34.00         -3.17     37.90   1519.56
 36.00         -3.58     31.14   1588.73
 38.00         -3.94     23.61   1643.59
 40.00         -4.24     15.42   1682.72
 42.00         -4.47      6.70   1704.92
 44.00         -4.63     -2.41   1709.26
 46.00         -4.70    -11.76   1695.13
 48.00         -4.69    -21.17   1662.20
 50.00         -4.59    -30.47   1610.53
 52.00         -4.38    -39.46   1540.53
 54.00         -4.07    -47.94   1453.03
 56.00         -3.65    -55.68   1349.27
 58.00         -3.10    -62.44   1230.98
 60.00         -2.42    -67.99   1100.34
 62.00         -1.62    -72.05    960.04
 64.00         -0.67    -74.36    813.33
 66.00          0.42    -74.63    664.00
 68.00          1.67    -72.56    516.40
 70.00          3.07    -67.85    375.54
 72.00          4.64    -60.16    247.02
 74.00          6.38    -49.18    137.12
 76.00          8.29    -34.54     52.80
 78.00         10.39    -15.88      1.70
 78.05         10.44    -15.36      0.92
 78.10         10.50    -14.84      0.17
 78.15         10.55    -14.31     -0.56

Last edited on
Thank you for the help. The only thing I'm having trouble with now is getting the formulas right.
double acceleration = 4.25-.015*(t*t)+(pow(6.07*t,2.751)/9995);
double velocity = 4.25*t - (pow(.015*t,3)/3)+(pow(6.07*t,3.751)/3.751*37491);
double distance = 90 + pow(4.75*t,2)/2 - pow(.015*t,4)/12+ (pow(6.07*t,4.751)/(4.751*37491));
closed account (48T7M4Gy)
4.25 - .015 t^2 + (6.07t^2.751)/(9995)
4.25 - .015*pow( t, 2) + 6.07*pow(t, 2.751)/9995
You didn't do anything for the other two does that mean mine are correct or you're just giving me an idea on how to do it?
closed account (48T7M4Gy)
No, sorry if I misled you. I didn't check them. I did notice you are making a blooper with the pow function. ct^x translates as c*pow(t,x) not pow(c*t,x)
closed account (48T7M4Gy)
4.25t - (.015t^3)/(3) + (6.07t^3.751)/(3.751(9995))
4.25*t - .015*pow(t,3)/3 +6.07*pow(t,3.751)/(3.751*9995)

90 + (4.25t^2)/(2) - (.015t^4)/(12) + (6.07t^4.751)/(4.751(37491))
90 + 4.25*pow(t,2)/2 - .015*pow(t,4)/12 + 6.07*pow(t,4.751)/(4.751*37491)

Be careful though, check mine. :-)
you could also turn some of those recurring coefficients into variables.

1
2
3
4
5
6
7
const double coeff1 = 4.25;
const double coeff2 = 0.015;
const double coeff3 = 6.07;

double acceleration = coeff1-coeff2*t*t+(pow(coeff3*t,2.751)/9995);

//etc 


This would make the equation line clearer if you had 'real' physical names for the coefficients (rather than my poor example of 'coeff1', 'coeff2' and 'coeff3').
Thank you all for the help. I got it figured out now I appreciate it. And also thanks
Topic archived. No new replies allowed.