Routines for working with lines in 3D