Clear Filters
Clear Filters

To make smaller hexagons at the points marked with cross in black

1 view (last 30 days)
We have the 2x2 hexagonal structure as shown in above figure.
Please take a note of the numbering of the vertices which is following a specific pattern.
I have numbered the smaller red coulured hexagons too for understanding, the further continued numbering can be understood by the pattern.
Please take a note that the read colured hexagons are formed at such vertices where three edges meet each other. The centers for drawing red coloured hexagons are saved in a separate matrix named second_matrix_values as shown below:
second_matrix_values =
1.0000 6.3480 3.6650
2.0000 0 7.3300
6.0000 6.3480 -3.6650
7.0000 12.6960 14.6600
10.0000 12.6960 7.3300
11.0000 19.0430 3.6650
Now I have shown one black coulred small hexagon and how it is formed at its positon. We need to make such black coulred hexagons at all the balck cross marks which i have provided in the image.
We have input as the side for the hexagons. Also we have cooridnates of blue coloured and red coloured hexagons.Thus using them we need to plot cooridnates for black coloured hexagon and thus make them.
please if any queries while understanding the problem then let us know.

Accepted Answer

Matt J
Matt J on 1 Jul 2023
Edited: Matt J on 1 Jul 2023
Forming the hexagons is easy enough using nsidedpoly (see below), but you need to use the delaunay triangulation to determine whether the intersection of the blue lines is a 'Y' or an upside down 'Y'.
s=1;
red=rotate(nsidedpoly(6,'SideLength',2*s),30);
black=arrayfun(@(i)subhex(red.Vertices(i,:),s) , [2,4,6] );
figure
plot(red,'FaceColor','r'); hold on
plot(black,'FaceColor','k'); hold off
axis equal
figure
plot(red,'FaceColor','r'); hold on
plot(rotate(black,60),'FaceColor','k'); hold off
axis equal
function p=subhex(v,s)
p=rotate(nsidedpoly(6,'SideLength',s,'Center',v),30,v);
end
  7 Comments
Matt J
Matt J on 1 Jul 2023
Edited: Matt J on 1 Jul 2023
Using isConnected, you can find, for a given point, the edge directions radiating out to nearby neighbors. Once you have those edges, you can start to analyze their geometry to see if they have the properties you want. I assume you want those separated by about 120 degrees and I assume you only want to consider edges of a certain length range, but I don't know what tolerances and ranges you plan to use. Likewise, you will want to test whether there is an edge that points straight up or down, which will determine whether you have an upright Y or an upside down Y. However, no edge will be perfectly horizontal or vertical, so you will need to decide on a tolerance for that as well.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!