[Math] How to Find Equation of Line Given Latitude, Longitude, Heading

spherical coordinatesspherical-geometry

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.

Best 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.