Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|cite|improve this question
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
up vote 2 down vote accepted

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.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.