Skip to content

Instantly share code, notes, and snippets.

Created March 11, 2013 21:39
Show Gist options
  • Save anonymous/5138020 to your computer and use it in GitHub Desktop.
Save anonymous/5138020 to your computer and use it in GitHub Desktop.
function sprache2()
T25 = 1:10;
YEARS = 25;
DISTANCE = 18;
coordinates = [0 0];
for t = T25
rows = size(coordinates, 1);
new_coordinates = [];
for i = 1:rows
for j = 1:round(rand()*3)+1
x = (rand() - rand()) * DISTANCE;
y = sqrt(DISTANCE * DISTANCE - x * x) * sign(rand() - rand());
new_coordinates = [new_coordinates ; coordinates(i,:) + [x y]];
end
end
coordinates = [coordinates ; new_coordinates];
if rows > 2
[hull, area] = convhull(coordinates(:, 1), coordinates(:, 2));
fill(coordinates(hull, 1), coordinates(hull, 2), 'c');
hold on;
scatter(coordinates(:,1), coordinates(:,2),'b');
hold off;
xlim([-100 100]);
ylim([-100 100]);
title([num2str(t * 25) ' years' ' and ' num2str(rows) ' villages']);
pause(0.1);
end
end
end
function a = get_max_distance(coordinates)
rows = size(coordinates, 1);
a = 0;
for i=1:rows
a = max(coordinates(i,:) * coordinates(i,:)', a);
end
end
function [A K] = parameter(a, t, rows, area)
A = a / t;
K = rows / area;
disp(A,K);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment