3

I'm waaay over my head here. Basically, I have a point (x, y) and a direction in degrees; I need to find a point that in n distance away from the given point in the specified direction.

I've tried looking up similar issues but everything is beyond my level of comprehension. Could somebody try to explain how I'd go about calculating this in as simple of terms as possible?

Thanks

  • As an aside, most libraries compute $\sin,\cos$ in radians, so you will need to convert your angle from degrees to radians. $d °$ corresponds to ${\pi \over 180} d$ radians. – copper.hat Dec 12 '13 at 16:14

2 Answers2

7

Let your point $(x, y)$ be $A$.

You gotta find the point a distance $n$ away at a given angle. Let $B(x_1,y_1)$ be your required point.. The easiest way to solve this, is to break it into components along the x and y axes.

By simple trigonometry:

enter image description here

$x_1 = x + n\cos\theta$
$y_1 = y + n\sin\theta$

Where $\theta$ is the angle given to you.

1

If $\theta$ is the angle between the direction and the positive direction of the $x$ axis, and $x_{new},y_{new}$ be the coordinates of the point you are looking for then:

$x_{new}=x+n\cos(\theta)\\y_{new}=y+n\sin(\theta)$

hhsaffar
  • 2,937