I have a line segment AB made up of two LatLngs, A and B.

I have another LatLng C and a bearing x degrees.

How can I calculate the point D where a line from C with bearing x degrees meets the line segment AB, if at all it meets?

All the lines and line segments are geodesic and are not straight. Pictorial representation

  • 2
    Can you add some picture for great understanding ? Commented Sep 25, 2017 at 18:43
  • Spherical geometry or ellipsoidal?
    – Spacedman
    Commented Apr 30, 2019 at 14:10

1 Answer 1


Pick a point D on the geodesic starting at C. Find the intersection of AB and CD using the method given in Section 8 of my paper Algorithms for geodesics. Finally, determine whether the intersection point lies within the segment AB and on the right side of C. Code to find the intersection is given in intersect.cpp.

  • Your link to intersect.cpp is broken.
    – Davis
    Commented Sep 27, 2017 at 17:42
  • 1
    Hmm, it works for me... Try going to the beginning of the discussion at sourceforge.net/p/geographiclib/discussion/1026621/thread/… and scrolling down to my answer on 2011-02-02. intersect.cpp is an attachment to this answer.
    – cffk
    Commented Sep 28, 2017 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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