• Remix
  • Share
  • New Entry

on 31 Oct 2021
  • 3
  • 122
  • 0
  • 0
  • 280
% Inspired by the original program:
% <https://stackoverflow.com/questions/3339692/modeling-hsv-color-space-in-matlab>
a=linspace(0,1,100);
b=linspace(1,0,50)';
c=b(end:-1:1);
d=ones(1,100);
e=b(:,d);
% First, create a 100-by-100 image to texture the cone with:
H=a(d',:); % 100-by-100 hues
S=[c(:,d);e]; % 100-by-100 saturations
V=[ones(50,100);e]; % 100-by-100 values
% Create an HSV image
C=hsv2rgb(cat(3,H,S,V));% Convert it to an RGB image
% Next, create the conical surface coordinates:
e=[2;2;0];
z0=zeros(1,100);
th=a*2*pi;
X=[z0;cos(th);z0];
Y=[z0;sin(th);z0];
Z=e(:,d);
% Finally, plot the texture-mapped surface:
surf(X,Y,Z,C,'FaceColor','texturemap','EdgeColor','none')% ,'FaceAlpha',0.5);
axis equal off
Remix Tree