# How to Find Equation of Line Given Latitude, Longitude, Heading

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.

## 1 Answer

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.

• So in this situation what is t? – tibsar May 6 '16 at 17:49
• 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 – qbert May 6 '16 at 18:01
• 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? – tibsar May 6 '16 at 18:22
• 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. – qbert May 6 '16 at 18:28
• 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. – qbert May 6 '16 at 18:59