Easy Trig - move an object to a position

I know this is a fairly simple trigonometry, however I have never been embedded in vectors, etc., and I don’t understand how this works.

Given the object at XY and the N direction, how do you move this object in that direction?

Also, given the am object at the XY point and the destination at the XY point, how do you move the object towards the destination?

I understand that there is a need to add vectors, etc.

Can someone please call me some easy digesting material?

Thanks.

+3
source share
3 answers

Given the object at XY and the N direction, how do you move this object in that direction?

(X, Y) - (NX, NY), . (X + NX, Y + NY).

, am XY XY, ?

(SX, SY) (DX, DY), (SX + t * (DX - SX), SY + t * (DY - SY) ) t = 0..1

+3

x, y, n d, :

x = x + cos(n) * d
y = y + sin(n) * d

x, y, x2, y2 d, :

dt = ((x2 - x)^2 + (y2 - y)^2) ^ 0.5

:

x = x + (x2 - x) * (d / dt)
y = y + (y2 - y) * (d / dt)
+2
0

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


All Articles