Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get point coordinates based on direction and distance (vector)

get point based on direction and distance

I need to find the coordinates of the second point. I know the angle between the points in radians and I also know the length of the vector.

I would really appreciate if someone could point me towards the solution.

like image 871
YemSalat Avatar asked Oct 18 '12 16:10

YemSalat


1 Answers

Given L as the length of the vector and Ang the angle

x2 = x1 + Math.cos(Ang) * L y2 = y1 + Math.sin(Ang) * L 

Oops... I just noted the top to bottom orientation of the Y axis... Konstantin Levin, you will need adapt slightly because the formulas above assume a typical trigonometric coordinates system. In your case the formulas should be:

x2 = x1 + Math.cos(Ang) * L    // unchanged y2 = y1 - Math.sin(Ang) * L    // minus on the Sin 

Also (what goes without saying, also goes in one says it...) the reference angle should be such that when y2 == y1 and x2 > x1, Ang should be zero, and it should increase as the second point is moved counter-clockwise around the first one.

like image 172
mjv Avatar answered Oct 13 '22 02:10

mjv