Search code examples
mathgeometrypolar-coordinatescartesian-coordinates

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 ?


Solution

  • 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