- /
-
Evolution
on 13 Oct 2024
- 15
- 198
- 0
- 0
- 845
Cite your audio source here (if applicable):
drawframe(20);
Write your drawframe function below
function drawframe(f)
% Use the gamma transformation from image processing
% to evolve a fish. Gamma=0 is a neutral transformation.
gammas = linspace(1/2.5,2.5,96);
gamma = gammas(f);
N = 100;
offset = 0.2;
% Upper body of fish
x = linspace(-1,1,N);
y = ones(1,N)-(x+offset).^2;
% concatenate tail edge
x = [x,ones(1,N)];
y = [y,linspace(1-(1+offset)^2,-1+(1+offset)^2,N)];
% # concatenate lower body
x = [x,linspace(1,-1,N)];
y = [y,-1+(linspace(1,-1,N)+offset).^2];
% concatenate lower mouth
mouth = -0.5;
x = [x,linspace(-1,mouth,N)];
y = [y,linspace(-1+(-1+offset)^2,0,N)];
% concatenate upper mouth, outline of fish done
x = [x,linspace(mouth,-1,N)];
y = [y,linspace(0,1-(-1+offset)^2,N)];
% distort fish outline by gamma transformation
x = gamma_transformation(x,gamma);
y = gamma_transformation(y,gamma);
clf
plot(x,y,'r-','Linewidth',4)
% make circle for fish eye
eyex = -0.5;
eyey = 0.5;
eyer = 0.1;
phase = linspace(-pi,pi,N);
x = eyex + eyer*cos(phase);
y = eyey + eyer*sin(phase);
% distort fish eye by gamma transformation
x = gamma_transformation(x,gamma);
y = gamma_transformation(y,gamma);
line(x,y,'Color','r','Linewidth',4)
title(sprintf('\\gamma = %0.2f',gamma),'FontSize',16)
axis equal
axis off
function y = gamma_transformation(x,gamma)
% gamma transformation on vector while preserving sign
y = sign(x).*exp(gamma*log(abs(x)));
end
end
Movie
Audio
This submission does not have audio.