DRAWAXISCUBE Draw a colored cube representing axis orientation. Usage: drawAxisCube(); Display a 3D unit cube with one corner located at position (0,0,0), and face colored according to the direction of their normal. Example drawAxisCube See also drawAxis3d, createCube, patch
0001 function p = drawAxisCube(varargin) 0002 %DRAWAXISCUBE Draw a colored cube representing axis orientation. 0003 % 0004 % Usage: 0005 % drawAxisCube(); 0006 % Display a 3D unit cube with one corner located at position (0,0,0), and 0007 % face colored according to the direction of their normal. 0008 % 0009 % Example 0010 % drawAxisCube 0011 % 0012 % See also 0013 % drawAxis3d, createCube, patch 0014 0015 % ------ 0016 % Author: David Legland 0017 % E-mail: david.legland@inrae.fr 0018 % Created: 2010-07-22, using Matlab 7.9.0.529 (R2009b) 0019 % Copyright 2010-2024 INRA - Cepia Software Platform 0020 0021 % extract handle of axis to draw on 0022 if isempty(varargin) 0023 hAx = gca; 0024 else 0025 if isAxisHandle(varargin{1}) 0026 hAx = varargin{1}; 0027 else 0028 error('If first argument is specified, it must be an axis handle'); 0029 end 0030 end 0031 0032 [n, e, f] = createCube; %#ok<ASGLU> 0033 0034 faceColors = [ ... 0035 1 1 0; ... 0036 0 0 1; ... 0037 1 0 0; ... 0038 0 1 1; ... 0039 1 0 1; ... 0040 0 1 0; ... 0041 ]; 0042 0043 p = patch(hAx, 'vertices', n, 'faces', f, ... 0044 'facecolor', 'flat', 'FaceVertexCData', faceColors); 0045