3D hexagonal mesh grid
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
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,
採用された回答
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 件のコメント
I arranged the x-y system with the code bellow:
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);
plot(X,Y,'or');

As you can see, it is shown in a 2D space. Now, I want to show it in a 3D space with various z values (z is constant for each layer) using this code:
m = 6;
n = 7;
[x,y,z] = meshgrid(0:m, 0:n, 0:1);
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);
z=z(4:8,1:4,:);
Dyuman Joshi
2023 年 10 月 18 日
What is the expected output?
S. Hannan
2023 年 10 月 18 日
Showing a multilayer system.
Dyuman Joshi
2023 年 10 月 18 日
It would help to have a visual example of the expected output.
From what I understood of the provided description -
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);
X = X(:);
Y = Y(:);
z_values = [0 0.5 1];
figure
for k=z_values
plot3(X,Y,k*ones(size(X)),'o','Color', rand(1,3))
hold on
end
%end
hold off

Do you want to join the dots in each 2D layer?
S. Hannan
2023 年 10 月 18 日
Thanks a lot.
No, I don't need to connect them.
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
2023 年 10 月 19 日
Thanks a lot.
Yes. this is the desired structure.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Surface and Mesh Plots についてさらに検索
参考
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
