1 ## Copyright (C) 2003 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_parallelogram (x,...)
18 ## x : 3 x 3 : Each column is a 3D point. The fourth corner is
19 ## x(:,1)-x(:,2)+x(:,3)
23 ## col, c : 3x1 : Color of surface
37 function s = vrml_parallelogram (x, varargin)
44 bcol = btran = bemit = brad = borad = bocol = boemit = nan;
47 op1 = " col emit tran balls border bcol btran bemit brad borad bocol boemit ";
48 df = tars (col,emit,tran,balls,border,bcol,btran,bemit,brad,borad,bocol,boemit);
49 s = read_options (varargin, "op1",op1, "default",df);
50 col=s.col; emit=s.emit; tran=s.tran; balls=s.balls; border=s.border;
51 bcol = s.bcol; btran = s.btran; bemit = s.bemit; brad = s.brad;
52 borad = s.borad; bocol = s.bocol; boemit = s.boemit;
55 if ! isnan (bcol) ||! isnan (brad) || ! isnan (bemit), balls = 1; end
57 if isnan (bcol), bcol = col; end
58 if isnan (btran), btran = tran; end
60 brad = (norm (x(:,1)-x(:,2))+ norm(x(:,1)-x(:,2)))/20;
64 x = [x(:,1:3), x(:,1)-x(:,2)+x(:,3)];
68 s = vrml_faces (x, (1:4)', "col",col, "tran", tran,"emit",emit);
70 # Decoration : balls on vertices
72 if isnan (bemit), bemit = emit; end
73 s = [s,vrml_points(x,"balls","rad",brad,"col",bcol,"tran",btran,"emit",bemit)];
78 if ! isnan (bocol) ||! isnan (borad) || ! isnan (boemit), border = 1; end
81 borad = (norm (x(:,1)-x(:,2))+ norm(x(:,1)-x(:,2)))/80;
84 if isnan (bemit), boemit = emit; else boemit = bemit; end
86 if isnan (bocol), bocol = col; end
88 if !balls # Make pretty junctions of cylinders
90 vrml_cyl(x(:,[1:columns(x),1]),"rad",borad,"emit",boemit,"col",col),\
91 vrml_points(x(:,1),"balls","rad",borad,"emit",boemit,"col",col)];
92 else # but only if balls don't cover them
93 s = [s,vrml_cyl(x(:,[1:columns(x),1]),"rad",borad,"emit",boemit)];