Draw a 3D line between two patches in matlab
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have two sets of coordinates in the form of:
v= (x1 y1 z1 a1 b1 c1,
x2 y2 z2 a2 b2 c2,
....,
xn yn zn an bn cn)
These are coordinates of vertices from two meshes. I would like to draw a 3D line joining a vertex in mesh1 to corresponding one in mesh2. I am using the `patch` function to display the two meshes. I tried the `plot3` and it seems to connect lines between points in single mesh only.
Code:
% vertex_coordinates contains vertices of matched keypoints obtained using index. Taking first 50 coordinates from the 2 meshes
v=[vertex_coordinates1(1:50,:), vertex_coordinates0(1:50,:)];
x=[v(:,1) v(:,4)];
y=[v(:,2) v(:,5)];
z=[v(:,3) v(:,6)];
figure
p0 = patch('Faces',faces0,'Vertices',vertex0,'FaceColor','blue','FaceAlpha',.5,'edgecolor', 'none');
p1 = patch('Faces',faces1,'Vertices',vertex1,'FaceColor','red','FaceAlpha',.2,'edgecolor', 'none');
axis equal off
hold on
plot3(x',y',z')
These coordinates are actually the vertices of the matched keypoints in the two meshes. I used indices of the matches to get the coordinates and draw a line between them. Is there something wrong with my code? Or should I be looking into thresholding my matches?
0 comentarios
Respuestas (1)
Jaswanth
el 25 de Oct. de 2024 a las 9:25
Hi,
To visualize the connections between corresponding vertices in two meshes using “plot3” function, you need to draw each line individually using a loop. This ensures that each line is plotted, connecting the exact start and end points between the two sets of coordinates.
Refer to the following modified code snipped showing how to loop through each pair of vertices using the “plot3” function:
for i = 1:size(x, 1)
plot3(x(i, :), y(i, :), z(i, :), 'k-', 'LineWidth', 1.5);
end
Hope it helps.
0 comentarios
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!