points=[1,1,1;1,1,-1;1,-1,1;-1,1,1];%;-1,-1,-1;1,-1,-1;-1,1,-1;-1,-1,1];
numOfRefs=size(points);
numOfRefs=numOfRefs(1);
scatter3(points(:,1), points(:,2), points(:,3), 'r*');

hold on;

actPoint=[rand()*2-1, rand()*2-1, rand()*2-1];
for i = 1:5000
    edge=randi(numOfRefs);
    selected=points(edge,:);
    actPoint=(actPoint+selected)/2;
    scatter3(actPoint(1), actPoint(2), actPoint(3), 'b*');
end

hold off;