This method is accurate enough only for small distances, because the curvature of the Earth is not accounted for. You can convert pseudo-spherical coordinates to planar coordinates, but a different method would probably be better for cases where the distance is large and accuracy is needed.
The key is to calculate the total distance between the start and end points. You can use Euclidean distance but, as stated, this is reasonably accurate only for smaller distances:
distance = sqrt((end.x - start.x) ** 2 + (end.y - start.y) ** 2)
You then know how long it will take to travel the entire distance:
timeToTravelDistance = distance / speed
From this, you can calculate the percentage of the distance you have traveled from start
to end
given time
:
percentageTraveled = time / timeToTravelDistance
Finally, interpolate:
result.x = start.x * (1 - percentageTraveled) + end.x * percentageTraveled
result.y = start.y * (1 - percentageTraveled) + end.y * percentageTraveled