Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get coordinates of a point in a coordinate system based on angle and distance

How to get coordinates of a point in a coordinate system when all I have is the origin coordinates (x, y) and the angle from the origin to the point and the distance from the origin to the point?

like image 202
just_user Avatar asked Mar 26 '12 12:03

just_user


People also ask

How do you calculate the coordinates of a point?

To find out the coordinates of a point in the coordinate system you do the opposite. Begin at the point and follow a vertical line either up or down to the x-axis. There is your x-coordinate. And then do the same but following a horizontal line to find the y-coordinate.


1 Answers

You use Math.cos, Math.sin like this:

pointX = x + distance * Math.cos(angle)
pointY = y + distance * Math.sin(angle)

enter image description here

Note about radians / degrees

Math.cos and Math.sin assumes the argument is given in radians (0…2π). If you have the angle in degrees (0…360), you would use Math.cos(Math.toRadians(angle)) for instance.

like image 107
aioobe Avatar answered Oct 25 '22 14:10

aioobe