Is there a function in MATLAB for detecting points inside a polyhedron?

111 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2012 年 1 月 6 日
回答済み: KAE 2020 年 2 月 18 日
The INPOLYGON function in MATLAB detects points inside a polygonal region. I would like to determine whether a given three-dimensional point is inside a polyhedron.

採用された回答

MathWorks Support Team
MathWorks Support Team 2012 年 1 月 6 日
The TSEARCHN and DELAUNAY functions in MATLAB can be used to detect whether a given three-dimensional point is inside a convex polyhedron for a small datasets. For example, consider the polyhedron defined by the vertices generated by the following commands:
n = 12; % Number of vertices
theta = 2*pi*rand(n,1)-pi; % Random theta
phi = pi*rand(n,1) - pi/2; % Random phi
x = cos(phi).*cos(theta); % Create x values
y = cos(phi).*sin(theta); % Create y values
z = sin(phi); % Create z values
The following commands determine if 20 randomly generated points within the unit square are also within the given polyhedron.
xyz = rand(3, n); % Generate random points
tri = delaunayn([x y z]); % Generate delaunay triangulization
tn = tsearchn([x y z], tri, xyz'); % Determine which triangle point is within
IsInside = ~isnan(tn) % Convert to logical vector

その他の回答 (1 件)

KAE
KAE 2020 年 2 月 18 日
You could use inpolyhedron from the FEX, discussed here.

カテゴリ

Help Center および File ExchangeDelaunay Triangulation についてさらに検索

製品


リリース

R14SP1

Community Treasure Hunt

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

Start Hunting!

Translated by