フィルターのクリア

Draw a circle inside a convex hull with its centre at the origin.

3 ビュー (過去 30 日間)
Hirak Basumatary
Hirak Basumatary 2019 年 1 月 22 日
編集済み: Matt J 2019 年 1 月 23 日
I am trying to draw a circle inside a convex hull with its centre at the origin. I have attached the code generating the points and the convex hull. In what way can i generate the incircle with its centre at the origin.
clc;
clear all;
A=[0 0;0 -5; 5 -5; 5 5;0 5;-2 2;-5 -5;5 8;-5 -8;-8 0;8 0]
x_axis=A(:,1)
y_axis=A(:,2)
k=convhull(x_axis,y_axis);
figure;
plot(x_axis(k),y_axis(k),'r-',x_axis,y_axis,'b*');

採用された回答

Matt J
Matt J 2019 年 1 月 23 日
編集済み: Matt J 2019 年 1 月 23 日
Use vert2lcon (Download) to find the inequality constraint matrices representing the polygon
[Aineq,bineq]=vert2lcon(A);
The bineq are actually distances of each of the sides of the polygon from the origin, so the radius of the largest inscribed circle should be
maxRadius = min(bineq);

その他の回答 (1 件)

KSSV
KSSV 2019 年 1 月 22 日
編集済み: KSSV 2019 年 1 月 22 日
clear all;
A=[0 0;0 -5; 5 -5; 5 5;0 5;-2 2;-5 -5;5 8;-5 -8;-8 0;8 0]
x_axis=A(:,1)
y_axis=A(:,2)
k=convhull(x_axis,y_axis);
figure;
hold on
plot(x_axis(k),y_axis(k),'r-',x_axis,y_axis,'b*');
C = [mean(x_axis(k)) mean(y_axis(k))] ;
plot(C(1),C(2),'*r')
% Get diatnces
d1 = pdist2(C,[x_axis(k) y_axis(k)]) ;
th = linspace(0,2*pi,1000) ;
x = C(1)+min(d1)*cos(th) ;
y = C(2)+min(d1)*sin(th) ;
idx = inpolygon(x', y',x_axis(k), y_axis(k)) ;
count = 0 ;
while nnz(idx)~=1000
count = count+1 ;
R = min(d1)-0.5 ;
idx = inpolygon(x', y',x_axis(k), y_axis(k)) ;
x = C(1)+R*cos(th) ;
y = C(2)+R*sin(th) ;
end
plot(x,y)
  4 件のコメント
Hirak Basumatary
Hirak Basumatary 2019 年 1 月 22 日
@kssv: Sir, i think what you have done is if the circle goes outside the convex hull, you have decreased the minimum distance "min(dl)" by 0.5. But, i was trying to solve with incircle touching the convex hull and without decreasing any min length. I am looking at an answer by John D Errico. Here is the link and trying to get the centre of the inscribed circle at the origin. Here's what i have been successful and still trying. actual.jpg
Hirak Basumatary
Hirak Basumatary 2019 年 1 月 22 日
編集済み: Hirak Basumatary 2019 年 1 月 22 日
Trying to get a circle inscribed like this. With its centre at the origin. ( drawing edited in paint, not matlab)

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by