DRAWEDGE3D Draw 3D edge in the current axes. drawEdge3d(EDGE) draws the edge EDGE on the current axis. EDGE has the form: [x1 y1 z1 x2 y2 z2]. No clipping is performed. drawEdge3d(AX,...) plots into AX instead of GCA. H = drawEdge3d(...) returns a handle H to the line object. Example figure; axis equal; view(3) p1 = [10 20 80]; p2 = [80 10 20]; p3 = [20 50 10]; drawEdge3d(gca, [p1;p2],[p2;p3],'b'); drawEdge3d([p1;p3],'k'); pause(1) drawEdge3d(gca, [p1 p2; p2 p3],'g'); drawEdge3d(p1(1), p1(2), p1(3),p3(1), p3(2), p3(3),'Color','r','Marker','x'); See also drawLine3d, clipLine3d, drawEdge --------- author : David Legland INRA - TPV URPOI - BIA IMASTE created the 18/02/2005. HISTORY 04/01/2007 remove unused variables 15/12/2009 "reprecate", and add processing of input arguments
0001 function varargout = drawEdge3d(varargin) 0002 %DRAWEDGE3D Draw 3D edge in the current axes. 0003 % 0004 % drawEdge3d(EDGE) draws the edge EDGE on the current axis. 0005 % EDGE has the form: [x1 y1 z1 x2 y2 z2]. No clipping is performed. 0006 % 0007 % drawEdge3d(AX,...) plots into AX instead of GCA. 0008 % 0009 % H = drawEdge3d(...) returns a handle H to the line object. 0010 % 0011 % Example 0012 % figure; axis equal; view(3) 0013 % p1 = [10 20 80]; 0014 % p2 = [80 10 20]; 0015 % p3 = [20 50 10]; 0016 % drawEdge3d(gca, [p1;p2],[p2;p3],'b'); 0017 % drawEdge3d([p1;p3],'k'); 0018 % pause(1) 0019 % drawEdge3d(gca, [p1 p2; p2 p3],'g'); 0020 % drawEdge3d(p1(1), p1(2), p1(3),p3(1), p3(2), p3(3),'Color','r','Marker','x'); 0021 % 0022 % See also 0023 % drawLine3d, clipLine3d, drawEdge 0024 % 0025 % --------- 0026 % author : David Legland 0027 % INRA - TPV URPOI - BIA IMASTE 0028 % created the 18/02/2005. 0029 % 0030 % HISTORY 0031 % 04/01/2007 remove unused variables 0032 % 15/12/2009 "reprecate", and add processing of input arguments 0033 0034 % Parse and check inputs 0035 if isAxisHandle(varargin{1}) 0036 hAx = varargin{1}; 0037 varargin(1) = []; 0038 else 0039 hAx = gca; 0040 end 0041 0042 % extract edges from input arguments 0043 nCol = size(varargin{1}, 2); 0044 if nCol == 6 0045 % all parameters in a single array 0046 edges = varargin{1}; 0047 varargin(1) = []; 0048 elseif nCol == 3 0049 if isequal(size(varargin{1}), [2 3]) && length(varargin) == 1 0050 % parameters are two points given as 2x3 0051 edges = [varargin{1}(1,:) varargin{1}(2,:)]; 0052 elseif isequal(size(varargin{1}), [2 3]) && ~isnumeric(varargin{2}) 0053 % parameters are two points given as 2x3 0054 edges = [varargin{1}(1,:) varargin{1}(2,:)]; 0055 varargin(1) = []; 0056 else 0057 % parameters are two points, or two arrays of points, of size N*3. 0058 edges = [varargin{1} varargin{2}]; 0059 varargin(1:2) = []; 0060 end 0061 elseif nargin >= 6 0062 % parameters are 6 parameters of the edge : x1 y1 z1 x2 y2 and z2 0063 edges = [varargin{1} varargin{2} varargin{3} varargin{4} varargin{5} varargin{6}]; 0064 varargin(1:6) = []; 0065 end 0066 0067 % Parse and check inputs 0068 isEdge3d = @(x) validateattributes(x,{'numeric'},... 0069 {'nonempty','size',[nan,6]}); 0070 defOpts.Color = 'b'; 0071 [~, edges, varargin] = ... 0072 parseDrawInput(hAx, isEdge3d, 'line', defOpts, edges, varargin{:}); 0073 0074 % identify indices of valid edge (not containing any NaN's). 0075 inds = sum(isnan(edges), 2) == 0; 0076 0077 % draw edges 0078 h = line(... 0079 [edges(inds, 1) edges(inds, 4)]', ... 0080 [edges(inds, 2) edges(inds, 5)]', ... 0081 [edges(inds, 3) edges(inds, 6)]', varargin{:}, ... 0082 'Parent', hAx); 0083 0084 % return handle to created Edges 0085 if nargout > 0 0086 varargout = {h}; 0087 end