Math Simulating movement in 2D

Math Simulating movement in 2D,math,trigonometry,Math,Trigonometry,I need assistance in simulating movement between 2 points in a plane. Consider two points P1:(x,y1) and P2:(x2,y2). I compute the distance between P1 and P2, say D, and I choose a random velocity, say V. Next, I compute the time required to move from P1 to P2, say T. Finally, I compute the equation of the straight line between P1 and P2 as y = mx + b. For example, let T = 10 seconds. For the first 9 seconds, I would like to generate points per second on the straight line until I reach point P2

I need assistance in simulating movement between 2 points in a plane. Consider two points **P1:(x,y1)** and **P2:(x2,y2)**. I compute the distance between P1 and P2, say **D**, and I choose a random velocity, say **V**. Next, I compute the time required to move from P1 to P2, say **T**. Finally, I compute the equation of the straight line between P1 and P2 as y = mx + b.

For example, let T = 10 seconds. For the first 9 seconds, I would like to generate points per second on the straight line until I reach point P2 at the 10th second. Could you please assist me in doing so.

**#1**

The best approach is to use parametric equations

```
x = x1 + t*(x2 - x1)
y = y1 + t*(y2 - y1)
```

where `t`

is the "time" parameter going from 0 to 1 (0.5 means for example halfway).

If you also like your movement to be "soft" (starting from zero velocity, then accelerating then slowing down and stopping on the arrival point) you can use this modified equation

```
w = 3*t*t - 2*t*t*t
x = x1 + w*(x2 - x1)
y = y1 + w*(y2 - y1)
```

The following is a plot of the `w`

curve compared to a linear distribution `t`

with 11 points (t=0.0, 0.1, ... 0.9, 1.0):

**#2**

**#3**