We got a curve, the curve represents the thrust of a engine. I have to divide the curve into 10 points(segments). So the program ask for the segments, then ask for a time for which thrust will be calculated. The thrust is calculated by
((time_entered - firstpoint) /(second point - first point)) *(thrust of second point - thrust of first point) + thrust of first point. I will create a function that calculated the thrust for wanted time.
Example output:
0.19 14.5
0.24 6.0
0.40 4.4
1.80 4.2
Enter a time: 1.0
The thrust at time 1.0 is 4.3
I'm confuse on how to read the segments into an array and how to call them to calculate the thrust.
When you are given a time t (e.g. 1.0), you look up from the table the lower and upper bound (0.4 and 1.8) and retrieve the corresponding thrust values (4.4 and 4.2) too.
Then you linearly interpolate the thrust at t. You have equation for that.