How can I calculate speed based on previous speed?

In summary, the conversation was about developing a Train Simulator program and calculating speed each frame. The current method involves using the equation (f/m)*elapsed frames*time between frames, but there are issues with framerate drops and changing forces. The speaker is looking for help in calculating speed based on the previous speed and time between frames. A solution was suggested to use the equation (f/m)*time between frames+ previous speed.
  • #1
Tim Leijten
28
1
Hi,

I am developing a Train Simulator kind of program where I calculate speed each frame.
I currently do that by:
Speed = (f/m)*elapsed frames*time between frames
This works, but goes wrong when there are framerate drops or if the force changes, that's why i want to calculate the speed with the speed in the previous frame, and the time a frame took to complete.
Can someone help me with calculating speed based on the previous speed and time between frames?Thanks
 
Physics news on Phys.org
  • #2
It's just a minor revision of the equation you have:
Speed = (f/m)*time between frames+ previous speed
 
  • Like
Likes Tim Leijten and anorlunda
  • #3
russ_watters said:
It's just a minor revision of the equation you have:
Speed = (f/m)*time between frames+ previous speed
Thank you!
 
  • Like
Likes russ_watters

FAQ: How can I calculate speed based on previous speed?

How do I calculate speed based on previous speed?

To calculate speed based on previous speed, you will need to know the distance traveled and the time it took to travel that distance. The formula for speed is distance divided by time. So, if you know the distance and time from the previous speed, you can use this formula to calculate the new speed.

Can I use the same formula to calculate speed for any type of motion?

Yes, the formula for speed (distance divided by time) can be used for any type of motion, as long as you have the distance traveled and the time it took to travel that distance.

What units should I use for distance and time when calculating speed?

The units for distance and time should be consistent when calculating speed. For example, if you measure distance in kilometers, then time should be measured in hours. It is important to use the same units in order to get an accurate calculation of speed.

Is speed the same as velocity?

No, speed and velocity are not the same. Speed is a measure of how fast an object is moving, while velocity is a measure of how fast an object is moving in a specific direction. So, while an object may have the same speed, it can have different velocities if it is moving in different directions.

Can I use previous speed to predict future speed?

Yes, you can use previous speed to make predictions about future speed. However, this will only be accurate if the conditions (such as distance and time) remain the same. Any changes in these conditions will result in a different speed calculation.

Back
Top