does convex hull intersect?

6 Ansichten (letzte 30 Tage)
CHANDRABHAN Singh
CHANDRABHAN Singh am 13 Jan. 2022
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

Akzeptierte Antwort

Matt J
Matt J am 13 Jan. 2022
Bearbeitet: Matt J am 13 Jan. 2022
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 Kommentare
Matt J
Matt J am 20 Jan. 2022
I cannot see where, in this code, you call intersectionHull().
CHANDRABHAN Singh
CHANDRABHAN Singh am 21 Jan. 2022
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;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Bjorn Gustavsson
Bjorn Gustavsson am 13 Jan. 2022
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

Kategorien

Mehr zu Bounding Regions finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by