Draw a 3D tetrahedron
15 ビュー (過去 30 日間)
古いコメントを表示
Hi
I'm new to Matlab.
how do I draw a tetrahedron?
The 4 corner points are given.
p1(0 0 0)
p2(0 1 1)
p3(1 0 1)
p4(1 1 0)
can anyone help?
4 件のコメント
Rik
2020 年 5 月 29 日
If you only want the points:
x = [0 0 1 1 0 1 0 1];
y = [0 1 0 1 0 0 1 1];
z = [0 1 1 0 0 1 1 0];
plot3(x,y,z,'*')
axis([-0.5 1.5 -0.5 1.5 -0.5 1.5])
Bjorn Gustavsson
2020 年 5 月 29 日
You can spice up Rik's idea by using the scatter3 function:
scatter3(x(1:4),y(1:4),z(1:4),34,1:4,'filled'),colorbar
That way you get the points coloured in order.
Then if you want to plot the triangular surfaces you can use fill3 to do that, for example the triangle with the three first points in the corners:
fill3(x(1:3),y(1:3),z(1:3),'r')
Then you'll have to do the same for the remaining triangles.
HTH
回答 (1 件)
Bjorn Gustavsson
2020 年 5 月 29 日
Have a look at the help and documentation of plot3. That function should give you what you need. The tedious thing you need to take into account when plotting the exges of a solid is that you need to make sure to plot each edge. This should get you started:
p1 = [0 0 0];
p2 = [0 1 1];
plot3([p1(1),p2(1)],[p1(2),p2(2)],[p1(3),p2(3)],'r.-')
hold on
HTH
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!