Faces of a Cube - Multifaceted Patches Documentation
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I was reading the literature on MathWorks Documentation regarding Multifaceted Patches and I am not able to understand how the face matrix was evaluated using the vertex matrix. Below I have attached the visaualization used in the Documentations to explain how the matrix is set up, I would apprecaite any pointers to break this down, thanks.
This is to answer the question I have for plotting 3D cubes using patches
0 Commenti
Risposta accettata
Steven Lord
il 18 Giu 2020
Modificato: Steven Lord
il 18 Giu 2020
Let's start out by labeling the points whose coordinates are given in the Vertices array.
v = [0 0 0; 1 0 0; 1 1 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1];
text(v(:, 1), v(:, 2), v(:, 3), string(1:8))
Since the points are in 3-dimensional space let's view the axes with a 3-D view.
view(3)
Now let's show just one of the faces.
hold on
face1 = [1 2 6 5];
P1 = patch(v(face1, 1), v(face1, 2), v(face1, 3), 'r');
The face1 vector indicates that this face is made up of points 1, 2, 6, and 5 in that order. [Connecting them in order [1 2 5 6] would make a different shape.] So the red patch has as its vertices points 1, 2, 6, and 5. Let's draw another face, but this time not a rectangle.
face2 = [8 7 5];
P2 = patch(v(face2, 1), v(face2, 2), v(face2, 3), 'c');
The cyan triangle has as its vertices points 8, 7, and 5.
Now look at the XData, YData, and ZData properties of the patch P1. Compare with the first columns of the x-coordinates, y-coordinates, and z-coordinates matrices shown in the documentation. Those are just the coordinates of the vertices 1, 2, 6, and 5. You could build a similar matrix (though with three rows, not four, since it only has three vertices) using the triangular patch P2 if you wanted to practice your understanding.
2 Commenti
Steven Lord
il 18 Giu 2020
If you can't run that text call because the release of MATLAB you're using predates string, use this instead:
text(v(:, 1), v(:, 2), v(:, 3), {'1', '2', '3', '4', '5', '6', '7', '8'})
Più risposte (1)
darova
il 18 Giu 2020
pretty clear for me
clc,clear
cla
x = [0 1 1];
y = [0 0 1];
patch(x,y,'r')
x = [x+2; 1 2 1.5]; % add second row
y = [y+2; 1 1 2];
patch(x',y','g') % plot data (read by columns)
legend('patch1: 1 face','patch2: 2 faces')
0 Commenti
Vedere anche
Categorie
Scopri di più su Polygons in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!