Update distanceTo function to work for line on same plane

Fix distanceTo function when both line segments are on the same plane (issue #1391). Add associated unit tests.