How to calculate new X, Y coordinates of a moving object

892 Views Asked by At

I am not 100% sure if this is the correct forum for this questions. I am sorry if it is slightly off topic.

I have a grid of 100m x 100m which objects travel from one position $(x_1, y_1)$ to another $(x_2, y_2)$. The objects move at 5 m/s. I have managed to calculate the distance between both points using the euclidean distance formula, but i am struggling with calculating the current x & y positions every second.

For example, if an object starts at $(15, 27)$ and is travelling to $(80, 10)$, how would i calculate the current $(x, y)$ coordinates after 1 sec?

1

There are 1 best solutions below

0
On BEST ANSWER

Basically, because your object is traveling with constant velocity, you can easily parameterize the motion in independent directions as follows. Notice the entire motion will travel the distance of $$d = \sqrt{(80-15)^2 + (10-27)^2} = \sqrt{4514} \approx 67.19 \text{m}$$ with speed $v = 5 \text{m/sec}$, which must happen over a total time of $$T = \frac{d}{v} \approx 13.44 \text{sec}.$$

Thus speed in $x$ is $$v_x = \frac{\Delta x}{T} = \frac{65}{T}$$ and in $y$ it must be $$v_y = \frac{\Delta y}{T} = \frac{10-27}{T} = \frac{-17}{T}.$$

Now you can parameterize: $$ x(t) = x_0 + v_x t = 15 + \frac{65t}{T}\\ y(t) = y_0 + v_y t = 27 - \frac{17t}{T}. $$

As a check on our work, note that $x(0) = x_0 = 15$ and $y(0) = y_0 = 27$, as trivially expected, but more importantly, $x(T) = 15+65 = 80$ and $y(T) = 27 - 17 = 10$, as required by your original problem statement.