function [p pc] = prog1(n)
%
% generate n random 2D points and compute the convex hull 
% plot the 2D points in red and 2D points on convex hull in blue
% return 2D point sets and 2D points that are on the convex hull 
%
p = rand(n,2);					% generate n random 2D points	
chull = convhulln(p);				% call Matlab built-in convex hull function 
figure(1);
clf
hold on
plot(p(:,1),p(:,2),'r.');			% plot 2D points in red
plot(p(chull(:,1)),p(chull(:,1),2),'bo');	% plot 2D points on the convex hull in blue
for i=1:1:size(chull,1)				% draw convex hull 
    plot([p(chull(i,1),1) p(chull(i,2),1)],[p(chull(i,1),2) p(chull(i,2),2)],'b');
end    
pc = p(chull(:,1),:);
