Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Project points using null()
Date: Sat, 30 Jun 2012 10:10:11 +0000 (UTC)
Organization: Rayne Institute
Lines: 30
Message-ID: <jsmja3$a79$1@newscl01ah.mathworks.com>
References: <i8i2vk$77u$1@fred.mathworks.com> <i8ij1r$39r$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1341051011 10473 172.30.248.35 (30 Jun 2012 10:10:11 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 30 Jun 2012 10:10:11 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3272409
Xref: news.mathworks.com comp.soft-sys.matlab:772559

Roger, 
Given a plane defined in constants XCoeff, YCoeff, CCoeff (see http://www.mathworks.co.uk/support/solutions/en/data/1-1AVW5/index.html?solution=1-1AVW5)
        z = XCoeff * x + YCoeff * y + CCoeff
how would you calculate Q and N for your method?

I tried 
Q = [1, 1, (XCoeff+YCoeff+CCoeff)];
N = [XCoeff, YCoeff, -1];

and while the projected points do all lie on the plane they are not orthogonally projected onto the plane?

Best wishes

Steven

>   Let P be the m x 3 array of the 3D points to be projected, let Q be the 1 x 3 vector of the given point on the plane, let N be the 1 x 3 vector of the normal direction to the plane, and let P0 be the m x 3 array of points orthogonally projected from P onto the plane.  Then do this:
> 
>  N = N/norm(N); % <-- do this if N is not normalized
>  N2 = N.'*N;
>  P0 = P*(eye(3)-N2)+repmat(Q*N2,m,1);
> 
> (You can also do that last line using bsxfun.)
> 
>   This can be derived from the single-point vector equation
> 
>  p0 = p - dot(p-q),n)*n
> 
> where p is a vector to a point to be projected, q is a vector to the point on the plane, n is the unit normal vector to the plane, and p0 is the orthogonal projection of p onto the plane. 
> 
> Roger Stafford