[x] Implement and test also two other methods instead of pythagoras.
haversine
local earth approximation as a flat. should be implemented from here, and used in the special case when p1=p3 that is when the two segments have a common endpoint.
[x] Create several examples to test for this case and observe where inconsistencies appear.
[x] Keep the cartesian version
[x] Fix the problems with indentation in your file
Fix the problem with add the following command in ~/.vimrc:
set expandtab
then command
:retab!
[x] Use comments in code, keep them short but descriptive