Fix major problem with pointToLineDistance function