This reverts commit c034c2a299. While the function works, it is subtly different for points exactly on a line - enough to cause problems with Shadow Warrior's waypoint implementation.
c034c2a299
g_pch.h