[Closed] How to calculate an object's speed?
Well that is a bit of a problem I think. Speed is a vector value, not a scalar. Meaning it has two properties, not one. There is no speed at 2f but speed between 1f and 2f, and speed between 2f and 3f. Speed (or more accurately velocity) is distance/time. you can get the average velocity over the period of these 3 frames. But in your example it would be zero at frame 2 as at frame 3 you have to be back where you started, so at frame 2 you need to achieve a complete stop before moving backwrads. To get that you do:
((distance p1 p0) + (distance p0 p2))/2 = (50 – 50)/2 = 0 units/frame
Makes sense?
50? Why 50? Isn’t it moving backwards in the next frame? If so, how can it be 50 if it changes direction?
in one frame it moves 50 units, in the next it goes back 50, in any case its still moving 50 units positive or negative. I didnt say overall too, just over one frame.
Distance over time, not total distance over total time – that would give you the average.
I think this is all a bit of semantics, if you get the speed at any given frame it is always 0, in the example provided you are assuming that the object slowed down and sped up but it is still only on that frame for an instant, but that doesn’t need to be the case. Saying that you are traveling at a given speed you need to to have two points of reference, where you were and where you are in a given time period. Given that, I can’t see the dealing with ticks is all that necessary unless you need to know the speed in smaller increments. This is the case when doing complex sims.
I think the absolute value of its speed at 2 frame is zero. But its acceleration is not zero.
Well, the case I was given is a special one. I think v = (distance p2 p1)/2 is enough for most circumstances.
:buttrock:
Yeah that’s why I would advocate ticks on each side of a frame if you need the ‘instantaneous’ speed at that frame.
In the above scenario if you do per frame ticks it’s
50u
-50u
if you use ticks its
50u
0u
-50u
Which is what you would see on the curve.