Calculation of the result of adding two speeds

I have a simple 2D system in which speed is represented as speed (some value) and direction (angle). If I have an object moving at a given speed v when another speed v 2 acts on it , I want to calculate the resulting speed v 3 .

I created the following illustration to explain the physical system that I want to implement. Speeds and angles may not be entirely accurate, because I don’t know how to calculate them - this is the essence of this issue, but they serve as a pretty close guide.

v 3, v 2 , v?

, , . TypeScript, JavaScript, ( ) .

+4
2

, , .

:

x = speed * cos(direction)
y = speed * sin(direction)

:

speed = sqrt(x * x + y * y)
direction = atan2(y, x)

, .

: : v, v2, v3 a, a2, a3:

x = v * cos(a)
y = v * sin(a)

x2 = v2 * cos(a2)
y2 = v2 * sin(a2)

x3 = x + x2
y3 = y + y2

v3 = sqrt(x3 * x3 + y3 * y3)
a3 = atan2(y3, x3)
+4

, , v1. , v1 /:

var v2;
while(simulation is running){
    v1 = v1 + v2;
}

v1, v2 x y.

, x = speed * cos(direction) y = speed * sin(direction) Rémi.

:

v1.x = v1.x + v2.x;
v1.y = v1.y + v2.y;

, tan(angle) = y / x,

angle = atan(y/x)

JavaScript var angle = atan2(v1.y, v1.x);.

(= )

speed = sqrt(v1.x * v1.x + v1.y * v1.y)
+1

All Articles