2010-07-26 137 views

回答

12

我猜你想創建以下Wikipedia圖像類似圓錐曲線:

的一種方式做到這一點與圖像繪製你的錐和texture map表面的HSV色彩空間。這裏是你如何能做到這一點:

% First, create a 100-by-100 image to texture the cone with: 

H = repmat(linspace(0, 1, 100), 100, 1);  % 100-by-100 hues 
S = repmat([linspace(0, 1, 50) ...   % 100-by-100 saturations 
      linspace(1, 0, 50)].', 1, 100); %' 
V = repmat([ones(1, 50) ...     % 100-by-100 values 
      linspace(1, 0, 50)].', 1, 100); %' 
hsvImage = cat(3, H, S, V);     % Create an HSV image 
C = hsv2rgb(hsvImage);      % Convert it to an RGB image 

% Next, create the conical surface coordinates: 

theta = linspace(0, 2*pi, 100); % Angular points 
X = [zeros(1, 100); ...   % X coordinates 
    cos(theta); ... 
    zeros(1, 100)]; 
Y = [zeros(1, 100); ...   % Y coordinates 
    sin(theta); ... 
    zeros(1, 100)]; 
Z = [2.*ones(2, 100); ...  % Z coordinates 
    zeros(1, 100)]; 

% Finally, plot the texture-mapped surface: 

surf(X, Y, Z, C, 'FaceColor', 'texturemap', 'EdgeColor', 'none'); 
axis equal 

,你應該得到如下圖所示:

enter image description here

+2

+1測試它,而且運作非常漂亮的(你可能要添加'「EdgeColor」,」 none''到SURF選項) – Amro 2010-07-27 06:27:19