I am trying to map a 2 D hexagonal lattice point for convex hull study. But I can only get rectangular lattice. Here is the code:
Map a hexagonal lattice on a 2D plane
u = 0:1:100;
if mod(u,2) == 0;
v = 0:2*sqrt(3):50*sqrt(3);
else
v = 1:2*sqrt(3):50*sqrt(3)
end
Define the area in which the convex hull should be constructed. Send all the data points to the convhull function.
[u,v] = meshgrid(u,v);
idx = sqrt((u-25).^2+(v-25).^2) <= 25 ;
u = u(idx);
v = v(idx);
c = convhull(u,v);
Plot the image
plot(u(c),v(c),'r-',u,v,'b.');
hold off