does convex hull intersect?

4 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Bounding Regions 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by