필터 지우기
필터 지우기

How to plot a polyhedron

조회 수: 44 (최근 30일)
Matteo Dentis
Matteo Dentis 2018년 2월 15일
답변: Jaswanth 2024년 7월 23일
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

답변 (1개)

Jaswanth
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.

카테고리

Help CenterFile Exchange에서 Bounding Regions에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by