1 ## Copyright (C) 2002 Etienne Grossmann <etienne@egdn.net>
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
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
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/>.
16 ## s = vrml_flatten (x [, d, w, col]) - A planar surface containing x
18 ## If the points x are not coplanar (or not in the affine plane {y|d'*y==w}),
19 ## the surface will not contain the points, but rather their projections on
20 ## the plane {y|d'*y==w}.
22 ## x : 3 x P : 3D points
23 ## d : 3 : normal to plane | Default : given by best_dir()
24 ## w : 1 : intercept of plane |
25 ## col : 3 : RGB color Default : [0.3,0.4,0.9]
27 ## s : string : vrml code representing the planar surface
29 function s = vrml_flatten (x, d, w, col)
32 if nargin <= 3 || isnan (col), col = [0.3,0.4,0.9]; end
33 if nargin <= 1 || isnan (d), [d,w] = best_dir (x);
34 elseif nargin <= 2 || isnan (w), w = mean (d'*x); end
35 if ! nargin, error ("vrml_flatten : no arguments given"); end
37 y = bound_convex (d,w,x);
39 faces = [ones(1,Q-2); 2:Q-1; 3:Q];
42 s = vrml_faces (y, faces, "col",col);