Draw a 3D tetrahedron
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Rik
el 29 de Mayo de 2020
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
el 29 de Mayo de 2020
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
Respuestas (1)
Bjorn Gustavsson
el 29 de Mayo de 2020
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 comentarios
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!