obtainVrep3d

PURPOSE ^

This is a subfunction.

SYNOPSIS ^

function vrep = obtainVrep3d(choice, param)

DESCRIPTION ^

 This is a subfunction.

 See also: obtainVRep, obtainHRep

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function vrep = obtainVrep3d(choice, param)
0002 % This is a subfunction.
0003 %
0004 % See also: obtainVRep, obtainHRep
0005 
0006 % The elk-library: convex geometry applied to crystallization modeling.
0007 %   Copyright (C) 2012 Alexander Reinhold
0008 %
0009 % This program is free software: you can redistribute it and/or modify it
0010 %   under the terms of the GNU General Public License as published by the
0011 %   Free Software Foundation, either version 3 of the License, or (at your
0012 %   option) any later version.
0013 %
0014 % This program is distributed in the hope that it will be useful, but
0015 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0016 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017 %   General Public License for more details.
0018 %
0019 % You should have received a copy of the GNU General Public License along
0020 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 
0022 switch choice
0023     % common bodies
0024     case 'cube'
0025         vrep.V = [0 0 0;0 0 1;0 1 0;0 1 1;...
0026                1 0 0;1 0 1;1 1 0;1 1 1;];
0027     case 'sphere'
0028         if isempty(param), param=20;end
0029         vrep = obtainSphere(param);
0030     case 'ball'
0031         vrep = obtainSphere(param);
0032     case 'cone'
0033         if isempty(param), param=20;end
0034         vrep = obtainCircle(param);
0035         vrep.V(:,3) = 0; % extend dimension of base
0036         vrep.V(end+1,:) = [0 0 1];
0037     case 'pyramid'
0038         % As a polygon is a bad approximation of a circle, a pyramid is a
0039         % bad approximation of a cone:
0040         vrep = obtainVrep3d('cone', param);
0041     case 'bicone'
0042         if isempty(param), param=20;end
0043         vrep = obtainCircle(param);
0044         vrep.V(:,3) = 0; % extend dimension of base
0045         vrep.V(end+1,:) = [0 0 1];  % upper tip
0046         vrep.V(end+1,:) = [0 0 -1]; % add lower tip
0047     case 'bipyramid'
0048         % As a polygon is a bad approximation of a circle, a pyramid is a
0049         % bad approximation of a cone:
0050         vrep = obtainVrep3d('bicone', param);
0051     case 'prism'
0052         vrep = obtainVrep2d('polygon', param);
0053         vrep.V(:,3) = 0; % extend dimension of base
0054         vrepMoved = moveVrep(vrep, [0 0 1]); % duplicate base
0055         vrep.V((end+1):(2*end),:) = vrepMoved.V;
0056     case 'antiprism'
0057         vrepBottom = obtainVrep2d('polygon', param);
0058         vrepTop = rotateVrep2d(vrepBottom, pi/param);
0059         vrepBottom.V(:,3) = 0; % extend dimension
0060         vrepTop.V(:,3) = 1; 
0061         vrep.V = [vrepBottom.V; vrepTop.V]; % duplicate base
0062         
0063     % special bodies
0064     case 'ikosaprism'
0065         vrep = [1 0 0;-1 0 0;0 sqrt(3) 0;...
0066             0 0 1;-1 sqrt(3) 1;1 sqrt(3) 1];
0067     case 'mixCubeOctahedron'
0068         CUB = obtainVrep3d('prism',4);
0069         CUB = moveVrep(CUB, [0 0 -0.5]);
0070         CUB = stretchVrep(CUB, [1/sqrt(2) 1/sqrt(2) sqrt(2)], [0 0 0]);
0071         POLY = stretchVrep(obtainVrep2d('polygon',4), [1 1], [0 0]);
0072         POLY.V(:,3) = 0;
0073         POLY = rotateVrep3d(POLY, 'z', pi/4, [0 0 0]);
0074         vrep.V = [CUB.V;POLY.V];
0075         
0076     % recursion into lower dimension
0077     otherwise
0078         vrep = obtainVrep2d(choice, param);
0079         % extend dimension
0080         vrep.V(:,3) = 0;
0081 end

Generated on Sat 18-Jul-2015 16:45:31 by m2html © 2005