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?
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.
You use Math.cos
, Math.sin
like this:
pointX = x + distance * Math.cos(angle)
pointY = y + distance * Math.sin(angle)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With