How do I identify points within a user defined shape?
2 views (last 30 days)
I have the folliwing code:
% genertae random data
xrange = [0 100];
yrange = [0 100];
% generating randomly placed points
points = rand(npoints, 2);
% normalizing the xy locations according to the parameters
points(:,1) = points(:,1)*diff(xrange) + xrange(1);
points(:,2) = points(:,2)*diff(yrange) + yrange(1);
plot(points(:,1),points(:,2), 'b+','linewidth',2, 'markersize',12);
[x,y] = ginput(1); % these 5 points can be used to make any kind of shape (preferable small in size) on the plot
h1 = text(x,y,int2str(i), ...
'Color', [1 0 0], ...
%plotting a line between all points
plot([a ; a(1)],[b ; b(1)], 'b-');
I want to find a way to identify all those points that lie within a user defined shape. A few examples of user defined shapes would be like:
I will appreciate if someone can kindly help me out. Thanks!