필터 지우기
필터 지우기

3D hexagonal mesh grid

조회 수: 4 (최근 30일)
S. Hannan
S. Hannan 2023년 10월 17일
댓글: S. Hannan 2023년 10월 19일
Hi,
I arranged the x-y space in hexagonal format as a layer. How can I add another similar layer on top with a distance in the z-direction?
I appreciate your help.
Thanks a lot,

채택된 답변

Matt J
Matt J 2023년 10월 17일
편집: Matt J 2023년 10월 17일
V=nsidedpoly(6).Vertices;
[X,Z]=ndgrid(V(:,1),0:3);
[Y,~]=ndgrid(V(:,2),0:3);
scatter3(X(:),Y(:),Z(:)); view(-60,70)
xlabel X; ylabel Y; zlabel Z
  댓글 수: 7
Matt J
Matt J 2023년 10월 18일
Now, I want to show it in a 3D space with various z values (z is constant for each layer) using this code:
I don't know what you think this changes about my answer. Isn't this what you want?
m = 6;
n = 7;
[x,y] = meshgrid(0:m, 0:n);
X = (3*x - mod(x+y,2)) / 2;
X=X+0.5;
X=X(4:8,1:4);
Y = (sqrt(3)/2)*y;
Y=Y(4:8,1:4);
Y=Y-Y(1,1);
V=[X(:),Y(:)];
[X,Z]=ndgrid(V(:,1),0:3);
[Y,~]=ndgrid(V(:,2),0:3);
scatter3(X(:),Y(:),Z(:)); view(-70,83)
xlabel X; ylabel Y; zlabel Z
S. Hannan
S. Hannan 2023년 10월 19일
Thanks a lot.
Yes. this is the desired structure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by