Originally Posted by

**metafolic** I have just started to use matlab and I am trying to find the shortest distance from a point P=(8,20) to a plane: v(a,b) = [6,0,0] + a[-2,1-0] + b[-1,0,1]

So far all I have done is to find the normal vector.

I know how to do this normally just unsure in matlab - any help would be great.

Thanks

You might try something like this:

Code:

% NOTES
% x*y' is the inner product or dot product of x and y
%
p=[8,2,0];
cc=[6,0,0];
v1=[-2,1,0];
v2=[-1,0,1];
p=p-cc; %translate everything so plane goes through origin
u1=v1/sqrt(v1*v1'); %gramm-schmitt orthogonalisation of v1 and v2
u2=v2-(u1*v2')*u1;
u2=u2/sqrt(u2*u2');
dd=p-(p*u1')*u1-(p*u2')*u2; %get component of p normal to the u1, u2 plane
dist=sqrt(dd*dd'); distance of p from the plane

But I have not checked this as I don't have Matlab or Octave on this machine.

RonL