- 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 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Jaswanth
on 23 Jul 2024
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 Comments
See Also
Categories
Find more on Bounding Regions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!