[Math and Art #1] Harmonograph

in #art6 years ago (edited)

Using Harmonograph, you can draw a lot of wonderful geometric shapes. Different frequency, amplitude and phase produce different geometrical shapes. Wonderful art!

<A Pentagon>

<A Hexagon>

<A devil's Spine>

Created via MATLAB

%% Setting variables
e = exp(1);
A = [1 1 1 1]'; % Amplitude
f = [4*e, pi, 4*e, pi]'; % frequency
p = [pi/2 pi/2 0 pi ]'; % phase
d = [0.02 0.002 0.02 0.002 ]'; % damping
t = 0 : 0.01 : 100; % time 
x = zeros(1, length(t)); % x coordinate
y = zeros(1, length(t)); % y coordinate

%% Plot
for i = 1 : 1 : length(t)
    x(i) = A(1) * sin(f(1) * t(i) + p(1)) * exp(-d(1) * t(i)) ...
    + A(2) * sin(f(2) * t(i) + p(2)) * exp(-d(2) * t(i));
    y(i) = A(3) * sin(f(3) * t(i) + p(3)) * exp(-d(3) * t(i)) ...
    + A(4) * sin(f(4) * t(i) + p(4)) * exp(-d(4) * t(i));
    z(i) = A(3) * sin(f(3) * t(i) + p(3)) * exp(-d(3) * t(i)) ...
    + A(4) * sin(f(4) * t(i) + p(4)) * exp(-d(4) * t(i));
end
plot(x, y)