Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move point in cartesian coordinate through distance in the given direction

I have a point in cartesian coordinate system for example : x = 3 & y = 5

And I want to get new coordinate of this point after a move through a distance in the given direction (in degrees).

How I can do for get new x and new y ?

like image 279
Rakim Faoui Avatar asked Jan 04 '17 13:01

Rakim Faoui


1 Answers

Well-known formulas from the school geometry:

new_x = x + distance * Math.Cos(angle_degrees * Math.Pi / 180)
new_y = y + distance * Math.Sin(angle_degrees * Math.Pi / 180)

Note that angle_degrees = "given direction" is measured from the positive x-axis moving toward the positive y-axis

like image 147
MBo Avatar answered Nov 02 '22 16:11

MBo