This formula handles the full 3D case.
http://mathworld.wolfram.com/Line-LineDistance.html
This gives the distance between the two points on two lines that are closest to one another. If this distance doesn't allow the two objects to pass one another, then they are on a collision course.
http://mathworld.wolfram.com/Line-LineDistance.html
This gives the distance between the two points on two lines that are closest to one another. If this distance doesn't allow the two objects to pass one another, then they are on a collision course.