Referensi : wikipedia
----------------------------------------- Polinomial kuadratik ----------------------------------
golden_ratio = (1+sqrt(5))/2
z = z^2+c
i = sqrt(-1)
-----------------------------------------------------------------------------------------------------
c = 1-golden_ratio
c = (golden_ratio-2)+(golden_ratio-1)*i
c = 0.285+0*i;
c = 0.45+0.1428*i;
c = -0.835-0.2321*i
c = -0.8+0.156*i
Matlab code
----------------------------------------- Polinomial kuadratik ----------------------------------
golden_ratio = (1+sqrt(5))/2
z = z^2+c
i = sqrt(-1)
-----------------------------------------------------------------------------------------------------
c = 1-golden_ratio
c = 0.285+0*i;
c = -0.70176-0.3843*i
c = -0.835-0.2321*i
Matlab code
File 1: Main programe
%-------------------------------------------- copy mulai dari sini ----------------------------------
% Julia Set_1
% Edited by Andri Husein
clc
clear all
i= sqrt(-1);
k = 100; % Number of iterations 100
Xr = [-2 2]; % x-axis range value
Yr = [-2 2]; % y-axis range value
% Reff : http://en.wikipedia.org/wiki/Julia_set
golden_ratio = (1+sqrt(5))/2;
c = 1-golden_ratio; % figure 1
%c = (golden_ratio-2)+(golden_ratio-1)*i; % figure 2
%c = 0.285+0*i; % figure 3
%c = 0.285+0.01*i; % figure 4
%c = 0.45+0.1428*i; % figure 5
%c = -0.70176-0.3843*i; % figure 6
%c = -0.835-0.2321*i; % figure 7
%c = -0.8+0.156*i; % figure 8
Julia_plot(c,k,Xr,Yr)
xlabel('x-axis','FontSize',12)
ylabel('y-axis','FontSize',12)
title('Julia Set','FontSize',12)
%-------------------------------------------- copy sampai sini ------------------------------------
File 2: Function, save dengan nama Julia_plot
%-------------------------------------------- copy mulai dari sini ----------------------------------
function Julia_plot(c,k,Xr,Yr)
n = 400;
i = sqrt(-1);
x = linspace(Xr(1,1),Xr(1,2),n);
y = linspace(Yr(1,1),Yr(1,2),n);
[X,Y] = meshgrid(x,y);
W = zeros(length(X),length(Y));
for m = 1:size(X,2)
for j = 1:size(Y,2)
[w,iter] = Julia(X(m,j)+Y(m,j)*i,c,k);
W(m,j) = W(m,j) + iter;
end
end
hold on;
%axis off;
colormap(jet); %pilihan warna 1
%colormap(summer); %pilihan warna 2
%colormap(cool); %pilihan warna 3
pcolor(W);
caxis([-20 180]); % default [-20 180]
shading interp;
hold off;
%----------------------------------
function [pri,it] = Julia(z,c,k)
R = max(abs(c),2);
d = 0;
while d < k
if abs(z) > R
pri = 1;
it = d;
return;
end
%-------------------------------------
z = z^2 + c; % Quadratic polynomials
%------------------------------------
d = d + 1;
end
pri = 0;
it = d;
%-------------------------------------------- copy sampai sini ------------------------------------
Copyright (c) 2006, Krzysztof Gdawiec
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 komentar :
Waah gambarnya jadi keren2 begitu ya ..
Sudah lama gak liat bentuk rumus2 dan bhs pemrograman, mumet sekarang liatnya. Hasil gambarnya saja ... :D
Waah gambarnya jadi keren2 begitu ya ..
Sudah lama gak liat bentuk rumus2 dan bhs pemrograman, mumet sekarang liatnya. Hasil gambarnya saja ... :D
Posting Komentar