# Perpendicular Vector of a plane with a lot of points

Discussion in 'MATLAB' started by Carlos Junior, Jun 23, 2011.

1. ### Carlos JuniorGuest

Hi,
Please, if anyone could help me I would be very grateful...

I have more than three 3-D points in a plane distribution and I need to know the perpendicular vector of this plane ... In my case, I have 36 points at the 3-D space... They are at the same plane... How could I know the perpendicular vector to this plane using all the points and not only three points ?

Very Thanks.

Carlos

Carlos Junior, Jun 23, 2011

2. ### Roger StaffordGuest

- - - - - - - - -
The answer to your question depends on how much validity is to be attributed to your statement "They are at the same plane". If this statement is literally and exactly true, then there is absolutely no point in using any more than three of the points to find an orthogonal direction. Any three which are non-colinear will do.

On the other hand if the points lie only approximately in a plane, then there is suddenly an urgent need to use all of the points to get the best possible answer.

For the exactly planar case, let P, Q, and R be any three (non-colinear) points. Then cross(Q-P,R-P) is a vector which is orthogonal to the plane of the points. End of story.

For the approximately planar case, you can make use of the 'mean' and 'svd' functions, but I will hold off until I hear that you are interested in this possibility.

Roger Stafford

Roger Stafford, Jun 23, 2011

3. ### Carlos JuniorGuest

------------------------

Hi Roger,
Thank you by the answer ... Indeed, I need the second situation you have cited:
" For the approximately planar case, you can make use of the 'mean' and 'svd' functions" ...

I have an ideal situation using the 3D Studio Max and MatLab to test the theory ... But, the project is also done at the real world where the points are not exactly at the same plane! Thus, what I need is to know how to find a perpendicular vector to the "approximately planar case" ...

Very thanks,

Carlos

Carlos Junior, Jun 23, 2011
4. ### Roger StaffordGuest

- - - - - - - - -
Let A be an n by 3 matrix where each row is one of the n points (that are approximately planar.)

A0 = bsxfun(@minus,A,mean(A,1)); % Subtract "mean" point
[~,~,V] = svd(A0,0);
p = V ,3); % Choose the eigenvector with the smallest singular value

Then 'p' is a unit vector orthogonal to the least squares best-fitting plane to the n points. This best plane passes through the point mean(A,1).

Roger Stafford

Roger Stafford, Jun 23, 2011