how to fit a plane through a set of 3D lines

I know how to fit a 2D line through a set of points but how can I fit a plane through a set of lines?

My lines are almost intersecting at a 3D point.

I am interested in suggestions for an a algorithmic approach to solve the problem, for example I know the least squares method for the 2D, is there any "equivalent" method for the 3D problem?

Thank you.

-
What do you mean to fit a plane? Should the plane contain all those lines? If yes, then the lines should be in the same plane. What do you mean by the lines almost intersecting? Two lines intersect, or are parallel or not in the same plane. –  Beni Bogosel Jun 1 '11 at 18:43
In 2D, one normally seeks to minimize the average 'vertical' distance (squared) from the points to the line. It's not clear, in your 3D case, what you'd like to minimize. –  leonbloy Jun 1 '11 at 18:46

Least Squares (suitably modified) still works reasonably well here - write your plane equation in the form $\hat{n}\cdot \vec{P} = d$, with (the components of) the normal vector $\hat{n}$ and the 'distance-from-origin' $d$ as your four parameters, plug in each of your lines to see how close they are to being parallel to this plane, and then minimize suitably. Note that you'll need to use something like a Lagrange Multiplier to cover the constraint that $\hat{n}$ actually be a normal vector.