Solution cubes to find the nearest point on the curve to the point

Good,

I have a shell that has its position defined as follows:

a.x = initialX + initialDX * time;

a.y = initialY + initialDY * time + 0.5 * gravtiy * time^2;

I want to be able to predict what obstacles this projectile will encounter in my environment. I plan to check the distance from the A of the nearest point of the curve to the point P .

I believe that at point A the tangent to the curve will be perpendicular to the vector AP and that the tangent to the curve at A will simply be the velocity V of the projectile at that point.

AP point V = 0

ap.x = initialX + initialDX * time - p.x;

ap.y = initialY + initialDY * time + gravity * time^2 - p.y;

v.x = initialDX;

v.y = initialDY + gravity * time;

=>

AP point V =

( 0.5 * gravity^2 ) * t^3 +

( 1.5 * gravity * initialDY  ) * t^2 +

( initialDX^2 + initialDY^2 + gravity * ( initialY - p.y ) ) * t +

( initialDX * ( initialX - p.x ) + initialDY * ( initialY - p.y ) )

, . , , , , , -, .

, . http://www.sosmath.com/algebra/factor/fac11/fac11.html

a = 0.5 * gravity^2;

b = 1.5 * gravity * initialDY;

c = initialDX^2 + initialDY^2 + gravity * ( initialY - p.y );

d = initialDX * ( initialX - p.x ) + initialDY * ( initialY - p.y );

A = ( c - ( b * b ) / ( 3 * a ) ) / a;

B = -( d + ( 2 * b * b * b ) / ( 27 * a * a ) - ( b * c ) / ( 3 * a ) ) / a;

workingC = -Math.pow( A, 3 ) / 27;

u = ( -B + Math.sqrt( B * B - 4 * workingC ) ) / 2; // Quadratic formula

s = Math.pow( u + B, 1 / 3 );

t = Math.pow( u, 1 / 3 );

y = s - t;

x = y - b / ( 3 * a );

x , A. , , , p.y , .

, , , , .

.

UPDATE:

, . , , :

a = 0.5 * gravity^2;

b = 1.5 * gravity * initialDY;

c = initialDX^2 + initialDY^2 + gravity * ( initialY - p.y );

d = initialDX * ( initialX - p.x ) + initialDY * ( initialY - p.y );

A = ( c - ( b * b ) / ( 3 * a ) ) / a;

B = -( d + ( 2 * b * b * b ) / ( 27 * a * a ) - ( b * c ) / ( 3 * a ) ) / a;

workingC = -Math.pow( A, 3 ) / 27;

discriminant = B * B - 4 * workingC;

then if discriminant < 0;

uc = new ComplexNumber( -B / 2, Math.sqrt( -discriminant ) / 2 ); 

tc = uc.cubeRoot( ); 

uc.a += B;

sc = uc.cubeRoot( ); 

yc = sc - tc; 

yc.a -= b / ( 3 * a ); 

x = -d / ( yc.a * yc.a + yc.b * yc.b ); 

- . -, ?

+3
1

, , .

, .

, , , , mutiply , , .

, -ve, , "i".

, (m, n), m + in. m - in = (m, -n), m n - .

P (x) = (x ^ 2 - 2m + (m ^ 2 + n ^ 2)) (x-r).

, P (x) = x ^ 3 - a_1 * x ^ 2 + a_2 * x - a_3, , r = a_3/(m ^ 2 + n ^ 2) (a_3 - , r (m ^ 2 + n ^ 2))

r r = a_1 - 2m (a_1 - , r + 2m).

: http://en.wikipedia.org/wiki/Complex_number

+4

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


All Articles