0
$\begingroup$

I need to find the equation of a line given X and Y coordinates (latitude and longitude) and a heading in degrees. I can assume that 0 degrees is North.

So for example, I might have that the point is (43.084926, -77.682241) and the heading is 90 degrees. From this I know that The line is pointing East, so I can easily get another latitude and longitude such as (43.085286, -77.682241), and can find the equation of the line using the two points, which is easy in this example:

y = -77.682241

However, when it gets to be any angle other then 0, 90, 180, or 270, I'm not sure how to get that second point and therefore, the line.

$\endgroup$
1
$\begingroup$

Some trigonometry should do the trick.

Say we have, (weirdly) setting North to be 0 degrees, 315 degrees and an initial latitude and longitude of $(x_0,y_0)=(0,0)$ for convenience, you can translate for a different example. Then we can use trigonometry and a vector representation to find another point on the line:

$(x_1,y_1)=(x_0,y_0)+t(\cos(45),\sin(45))=(x_0,y_0)+t(\sqrt{2}/2,\sqrt{2}/2)$,

where I take 45 degrees to be where it usually is for the unit circle, and for some t positive or negative. This will define the set of all points spanned by your given line. Since you only need two points to define a line, set t to be whatever you want and use these two points to get a point slope form or something more comfortable.

$\endgroup$
  • $\begingroup$ So in this situation what is t? $\endgroup$ – tibsar May 6 '16 at 17:49
  • $\begingroup$ t is arbitrary; it could be anyting. pick any nonzero t to get a second point on this line, and then use $y-y_0=m(x-x_0)+b$ for a more familiar form $\endgroup$ – qbert May 6 '16 at 18:01
  • $\begingroup$ Okay, so basically, given any angle $(x_{1}, y_{1})$ is the point I'm trying to get.$(x_{0}, y_{0})$is the point I'm given. $t$ can be anything other than 0, since I'm trying to find any point on the line. In $(cos(45), sin(45))$ 45 is chosen because $360-315$, so for any angle I can do $cos(360 - heading), sin(360 - heading)$, right? $\endgroup$ – tibsar May 6 '16 at 18:22
  • $\begingroup$ I agree with everything except the last bit. you have to be careful with the angles. I would think about how many degrees you moved counterclockwise from 0, or due north, and then convert to the regular unit circle. Or better, draw a triangle and use that to derive the new latitude and longitude, which will be the base and height respectively. $\endgroup$ – qbert May 6 '16 at 18:28
  • 1
    $\begingroup$ I would do angle given minus 90 since your coordinate system is the unit circle rotated by 90 degrees to the left (0 degrees was moved to 90 degrees as east was moved to north). So applying sine and cosine to angle minus 90 should do the trick. $\endgroup$ – qbert May 6 '16 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.