does convex hull intersect?

5 ビュー (過去 30 日間)
CHANDRABHAN Singh
CHANDRABHAN Singh 2022 年 1 月 13 日
コメント済み: CHANDRABHAN Singh 2022 年 1 月 21 日
Hello. The codes shown produces two convhull. I want to generate a parameter p such that
if convhull intersect, p=false
else, p=true. Any help or suggetions regarding this. Thanks in advance.
figure
for ii=1:2
rand_theta(ii,:) = sort(rand(1,10)).*2*pi;
rand_beta(ii,:) = sort(rand(1,10)).*pi - pi/2;
radius = 5;
[x(ii,:), y(ii,:), z(ii,:)] = sph2cart(rand_theta(ii,:), rand_beta(ii,:),radius);
%[X, Y, Z] = meshgrid(x,y,z);
k = convhull(x(ii,:), y(ii,:), z(ii,:));
trisurf(k, x(ii,:), y(ii,:), z(ii,:));
hold on;
end

採用された回答

Matt J
Matt J 2022 年 1 月 13 日
編集済み: Matt J 2022 年 1 月 13 日
You can use intersectionHull() from
for ii=1:2
V{ii}=[x(ii,:); y(ii,:); z(ii,:)]';
end
S=intersectionHull('vert',V{1},'vert',V{2});
If S.vert is empty, there is no intersection.
  3 件のコメント
Matt J
Matt J 2022 年 1 月 20 日
I cannot see where, in this code, you call intersectionHull().
CHANDRABHAN Singh
CHANDRABHAN Singh 2022 年 1 月 21 日
I have specified piece of code using intersectionhull below. Line 58 of the code.
for ii= 1:numel(agg_num)
V{1}=[x_plot(agg_num(ii),1:theta_m(agg_num(ii),1)); y_plot(agg_num(ii),1:theta_m(agg_num(ii),1)); z_plot(agg_num(ii),1:theta_m(agg_num(ii),1))]';
V{2}=[x_plot(jj,1:theta_m(jj,1)); y_plot(jj,1:theta_m(jj,1)); z_plot(jj,1:theta_m(jj,1))]';
S=(intersectionHull('vert',V{1},'vert',V{2}));
s=isempty(S.vert);
while_inner_loop = s;

サインインしてコメントする。

その他の回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2022 年 1 月 13 日
You should have two file-exchange packages that solves your problem:
They should be able to return the intersection-points of your conv-hull curves. I don't know how they behave for peculiar edge-cases like osculating curves and potentially similar corners (and how you want to solve those considering our finite precision...)
HTH

カテゴリ

Help Center および File ExchangeBounding Regions についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by