geometry

Added some missing routines and used a simpler expression to compute the perpendicular segment and to compute the distance from a point to a line.