フィルターのクリア

How to plot closed polygon from set of random points with edges not intersecting?

21 ビュー (過去 30 日間)
akash sonnad
akash sonnad 2018 年 5 月 11 日
コメント済み: KSSV 2018 年 5 月 14 日
I have set of random points in 2D plane, and have to make a closed polygon without any intersection between edges. There is a possibility that one or more polygons can be drawn. How do I get all those possible polygons along with their perimeter.
  11 件のコメント
akash sonnad
akash sonnad 2018 年 5 月 11 日
The points are random. If i give you certain points, it may work for those. What I need is a generic solution. Can anyone throw some light on polyshape?
Guillaume
Guillaume 2018 年 5 月 11 日
polyshape does not have any function to do what you want, so it's not clear what light you need. As I said, there's nothing built into matlab to do that search, at least in base matlab. There's an example in the optimisation toolbox for something similar though.

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

採用された回答

KSSV
KSSV 2018 年 5 月 11 日
編集済み: KSSV 2018 年 5 月 11 日
How about this?
N = 100 ;
x = rand(1,N) ;
y = rand(1,N) ;
P = [x; y]; % coordinates / points
c = mean(P,2); % mean/ central point
d = P-c ; % vectors connecting the central point and the given points
th = atan2(d(2,:),d(1,:)); % angle above x axis
[th, idx] = sort(th); % sorting the angles
P = P(:,idx); % sorting the given points
P = [P P(:,1)]; % add the first at the end to close the polygon
plot( P(1,:), P(2,:), '.-r');
  2 件のコメント
akash sonnad
akash sonnad 2018 年 5 月 13 日
Thanks!
KSSV
KSSV 2018 年 5 月 14 日
Thanks is accepting the answer...:)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by