- meshgrid: https://www.mathworks.com/help/matlab/ref/meshgrid.html?searchHighlight=meshgrid&s_tid=srchtitle_support_results_1_meshgrid
- convhull: https://in.mathworks.com/help/matlab/ref/convhull.html?searchHighlight=convhull&s_tid=srchtitle_support_results_1_convhull
- trisurf: https://www.mathworks.com/support/search.html?q=trisurf&page=1
How to plot a polyhedron
조회 수: 21 (최근 30일)
이전 댓글 표시
Hi all,
I have a cloud of points that I have obtained by computing T = A*W where W = [w1 w2 w3 w4]', A is a 3x4 matrix and T is a 3x1 matrix. All the parameters wi can be equal to [-1 0 1]. Hence, I found all the combination of W compunting by varying each wi and finally I have obtained all the 81 points T(:,i). My goal is to depict the polyhedron, or 3D polygon, which is described by all the external points of the cloud T(:,i). I started to use the command "fill3(x,y,z,c)" and the results is quite good, but I'm doing it "by hands" and the cloud of points is not easily to visualize and hence is too difficoult to find all the vertices to plot each face of the polyhedron. It will be good if I can plot only the external points of the cloud or if there is a matlab command which plot the external surfaces of a cloud of points. I attach the picture of the cloud of points and some parts of the polygon I already found manually. Blue, red and green lines are related to x, y and z axis I order to help the visualization.
Someone can help me? Thank you!
Matteo
댓글 수: 0
답변 (1개)
Jaswanth
2024년 7월 23일
Hi,
To visualize the polyhedron enclosing your point cloud in MATLAB, you can utilize the convhull function, which calculates the convex hull in 3D space. The convex hull is essentially the smallest convex shape that can contain all the points in your dataset.
Please refer to the following example code that can help you to plot only the external points of the cloud:
% Generate some sample data (replace this with your actual data)
[x, y, z] = meshgrid([-1, 0, 1], [-1, 0, 1], [-1, 0, 1]);
T = [x(:), y(:), z(:)]';
% Compute the convex hull
K = convhull(T(1,:), T(2,:), T(3,:));
% Plot the polyhedron
figure;
trisurf(K, T(1,:), T(2,:), T(3,:), 'FaceColor', 'cyan', 'FaceAlpha', 0.8);
In this code, meshgrid is used to create a grid of points in 3D space for demonstration purposes. The convhull function computes the convex hull from the points in T, and trisurf is then used to plot the surface of this convex hull with triangular faces. Replace the sample data generation with your actual point cloud data to visualize your specific polyhedron. This approach will help you automatically identify and plot the external surfaces of your point cloud, eliminating the need to manually determine the vertices.
Kindly refer to the following MathWorks documentation to know more about the functions discussed above:
I hope the information provided above is helpful.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Bounding Regions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!