Calculation of intersection point based on angle and speed

I have a vector consisting of a point, speed and direction. We will call this vector R. And another vector, which consists only of a point and speed. No direction. We will call it T. Now I am trying to find the shortest intersection point of these two vectors. Since T has no direction, this proves difficult. I managed to create a formula that works in CaRMetal, but I can't get it to work in Python. Can someone suggest a more efficient way to solve this problem? Or solve my existing formula for X?

Formula:

Formula
(source: bja888.com )

Key:

Definitions
(source: bja888.com )

Where o or k is the speed difference between the vectors. R.speed / T.speed

+3
4

, :

p q - , d e - . t , :

(1) p + t * d = q + t * e

e, :

(2) e = (p-q)/t + d

t, , s ( ):

e s,

(3) e 1 2 + e 2 2= s 2

-

(4)

I) a = sum (p-q)/(s 2 -sum (d 2))

II) b = 2 * sum (d * (pq))/(s 2 -sum (d 2))

III) c = -1

IV) a + b * t + c * t 2= 0

(2 2d, 3 3d)

, ; -)

+1
  • , , A, . , .
  • A . , B. , 1.

, ...

:

A , B A. , A . d.

B, , A , A , d2.

. d3 = d - d2   d3.

:

A :

Sb = B, ,

alpha = atan2 (a_y-b_y, a_x-b_x)

Vb_x = Sb * cos ()

Vb_y = Sb * sin (alpha)

A Sa, :

Vb_x '= Sb * cos () + Sa * cos ()

Vb_y '= Sb * sin () + Sa * sin ()

alpha '= atan2 (Vb_y', Vb_x ')

, ...

0

, . ,

.

Point A         - the position associated with vector R.
Point B         - the position associated with vector T.
Vector AB    - the vector from point A to point B
Angle beta  - the angle between vector R and vector AB.
Angle theta - the angle between vector T and vector AB

theta = asin( |R| * sin(beta) / |T| )

beta = acos (AB.xR.x + AB.yR.y)

, asin acos -PI/2 PI/2.

beta  = atan2( R.y, R.x  ) - atan2( AB.y, AB.x )
x        = |R| * sin(beta) / |T|
y        = 1 + sqrt( 1 - x*x )
theta = 2*atan2( y, x )

, x > 1 R

..

0

Well, if I understand correctly, you have

R = [xy0, v, r] T = [xy1, v]

If you are concerned about the shortest intersection point, this will be achieved when your positions are the same, and in Euclidean space this will also lead to the fact that the direction of the second β€œthing” will be perpendicular to the first. You can write down equations for this and easily solve them.

-2
source

Source: https://habr.com/ru/post/1724612/


All Articles