1 ## Copyright (C) 2007-2010 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 (bnds,...)
18 ## bnds = [xmin, ymin, zmin; xmax, ymax, zmax]
22 ## col, c : 3x1 : Color of surface
36 function s = vrml_parallelepiped (bnds, varargin)
43 bcol = btran = bemit = brad = borad = bocol = boemit = nan;
46 error ("bnds must be a 2 x 3 matrix, not a %s",typeinfo(bnds));
48 if prod (size (bnds)) != 6
49 error ("bnds must be 2 x 3, not %s",sprintf("%i x ",size(bnds))(1:end-3));
52 op1 = " col emit tran balls border bcol btran bemit brad borad bocol boemit ";
53 df = tars (col,emit,tran,balls,border,bcol,btran,bemit,brad,borad,bocol,boemit);
54 s = read_options (varargin, "op1",op1, "default",df);
55 col=s.col; emit=s.emit; tran=s.tran; balls=s.balls; border=s.border;
56 bcol = s.bcol; btran = s.btran; bemit = s.bemit; brad = s.brad;
57 borad = s.borad; bocol = s.bocol; boemit = s.boemit;
60 if ! isnan (bcol) ||! isnan (brad) || ! isnan (bemit), balls = 1; end
62 if isnan (bcol), bcol = col; end
63 if isnan (btran), btran = tran; end
65 brad = (max (abs (diff(bnds))))/20;
69 x = [bnds([1 2 2 1 1 2 2 1],1)';\
70 bnds([1 1 2 2 1 1 2 2],2)';\
71 bnds([1 1 1 1 2 2 2 2],3)'];
81 s = vrml_faces (x,faces,"col",col, "tran", tran,"emit",emit);
83 # Decoration : balls on vertices
85 if isnan (bemit), bemit = emit; end
86 s = [s,vrml_points(x,"balls","rad",brad,"col",bcol,"tran",btran,"emit",bemit)];
91 if ! isnan (bocol) ||! isnan (borad) || ! isnan (boemit), border = 1; end
94 borad = (norm (x(:,1)-x(:,2))+ norm(x(:,1)-x(:,2)))/80;
97 if isnan (bemit), boemit = emit; else boemit = bemit; end
99 if isnan (bocol), bocol = col; end
101 if !balls # Make pretty junctions of cylinders
103 vrml_cyl(x(:,[1:columns(x),1]),"rad",borad,"emit",boemit,"col",col),\
104 vrml_points(x(:,1),"balls","rad",borad,"emit",boemit,"col",col)];
105 else # but only if balls don't cover them
106 s = [s,vrml_cyl(x(:,[1:columns(x),1]),"rad",borad,"emit",boemit)];