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!