- /
-
Hue phase loop complex function graph
on 1 Nov 2024
- 29
- 149
- 0
- 0
- 733
Cite your audio source here (if applicable):
drawframe(1);
Write your drawframe function below
function drawframe(f)
c = cos(pi/48*f)+1i*sin(pi/48*f);
%设置网格范围和分辨率
n = 1e3;
a = 8;
x = linspace(-a, a, n);
y = linspace(-a, a, n);
[X, Y] = meshgrid(x, y);
% 定义复变函数
z = X + 1i * Y;
F = (z.^2 + c)^2 ./ (z.^2 - c);
% 计算相位
phase = angle(F);
% 相位归一化[0,2*pi]
norm_phase = mod(phase,2*pi);
% 色相hue
%参考https://dlmf.nist.gov/help/vrml/aboutcolor#S2
q1 = find(norm_phase<pi*0.5);
q2 = find(norm_phase<pi&norm_phase>=pi*0.5);
q3 = find(norm_phase<pi*1.5&norm_phase>=pi);
q4 = find(norm_phase<pi*2&norm_phase>=pi*1.5);
hue(q1) = norm_phase(q1)/(3*pi);
hue(q2) = (norm_phase(q2)*4/3-pi/3)/(2*pi);
hue(q3) = (norm_phase(q3)*2/3+pi/3)/(2*pi);
hue(q4) = (norm_phase(q4)*2/3-pi/3)/pi;
hue = reshape(hue,n,n);
% RGB 颜色
% 参考https://blog.csdn.net/slandarer/article/details/125617555
% 饱和度H = 0.8*(1-2^(-|z|))
hsvMesh = cat(3,hue,0.8*(1-2.^(-abs(F))),ones(n));
rgbMesh = hsv2rgb(hsvMesh);
Z=zeros(size(X));
%surf绘图
surf(X,Y,Z,'EdgeColor','none','CData',rgbMesh)
axis equal;axis([-2,2,-2,2]);
view(0,90);
set(gcf,'Color', 'black')
end