Find the centers of multiple polygons
I have an nx3 matrix that holds the locations for the vertices of a chain of hexagonal shapes (images 1, 2).
Side-note: The coordinates for the vertices of these hexagons are not in any logical order within the matrix. The coordinates were retrieved from an STL file which may be the reason why.
<</matlabcentral/answers/uploaded_files/14983/1.png>>
<</matlabcentral/answers/uploaded_files/14984/2.png>>
I’m trying to find the centroid of each of these hexagons and index those six points to its respective centroid. Once I’ve indexed these, I plan on writing some more code to manipulate the six points farther away from their respective centroids – making the hexagons larger and making my structure thicker [ _they are currently too thin_ ] (image 3).
<</matlabcentral/answers/uploaded_files/14985/3.png>>
My problem is the centroid and indexing part. I’ve tried clustering the hexagons into n/6 clusters using the k-means and subclust functions, but there’re always points that do not fall in the center of a hexagon (image 4).
<</matlabcentral/answers/uploaded_files/14986/4.png>>
Would anyone know what I should try?
[I’ve also attached the matrix, in case you would like to play around with the data as well.]I have an nx3 matrix that holds the locations for the vertices of a chain of hexagonal shapes (images 1, 2).
Side-note: The coordinates for the vertices of these hexagons are not in any logical order within the matrix. The coordinates were retrieved from an STL file which may be the reason why.
<</matlabcentral/answers/uploaded_files/14983/1.png>>
<</matlabcentral/answers/uploaded_files/14984/2.png>>
I’m trying to find the centroid of each of these hexagons and index those six points to its respective centroid. Once I’ve indexed these, I plan on writing some more code to manipulate the six points farther away from their respective centroids – making the hexagons larger and making my structure thicker [ _they are currently too thin_ ] (image 3).
<</matlabcentral/answers/uploaded_files/14985/3.png>>
My problem is the centroid and indexing part. I’ve tried clustering the hexagons into n/6 clusters using the k-means and subclust functions, but there’re always points that do not fall in the center of a hexagon (image 4).
<</matlabcentral/answers/uploaded_files/14986/4.png>>
Would anyone know what I should try?
[I’ve also attached the matrix, in case you would like to play around with the data as well.] I have an nx3 matrix that holds the locations for the vertices of a chain of hexagonal shapes (images 1, 2).
Side-note: The coordinates for the vertices of these hexagons are not in any logical order within the matrix. The coordinates were retrieved from an STL file which may be the reason why.
<</matlabcentral/answers/uploaded_files/14983/1.png>>
<</matlabcentral/answers/uploaded_files/14984/2.png>>
I’m trying to find the centroid of each of these hexagons and index those six points to its respective centroid. Once I’ve indexed these, I plan on writing some more code to manipulate the six points farther away from their respective centroids – making the hexagons larger and making my structure thicker [ _they are currently too thin_ ] (image 3).
<</matlabcentral/answers/uploaded_files/14985/3.png>>
My problem is the centroid and indexing part. I’ve tried clustering the hexagons into n/6 clusters using the k-means and subclust functions, but there’re always points that do not fall in the center of a hexagon (image 4).
<</matlabcentral/answers/uploaded_files/14986/4.png>>
Would anyone know what I should try?
[I’ve also attached the matrix, in case you would like to play around with the data as well.] kmeans, centroids, indexing MATLAB Answers — New Questions