Snach lineClipping.py from https://github.com/scienceopen/cv-utils/blob/master/lineClipping.py