]> Creatis software - CreaPhase.git/blob - octave_packages/vrml-1.0.13/proplan.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / vrml-1.0.13 / proplan.m
1 ## Copyright (C) 2002 Etienne Grossmann <etienne@egdn.net>
2 ##
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
6 ## version.
7 ##
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 ## details.
12 ##
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
15
16 ##       x = proplan(x,d,v=1)
17 ##
18 ## orthogonally project x to the affine plane d*x == v
19
20 function x = proplan(x,d,v)
21
22 if exist("v")!=1, v = 1 ;end
23
24 d = d(:) ;
25 N = prod(size(d)) ;             # Assume x is NxP
26
27 v = v/norm(d);
28 d = d/norm(d);
29
30 p = (v*d)*ones(1,size(x,2));
31
32 x -= d*d'*(x-p) ;
33 # x = p + (eye(N)-d*d')*(x-p) ;
34 endfunction
35