Create coordinates on a convex hull

2 ビュー (過去 30 日間)
Kwek Lawrence
Kwek Lawrence 2019 年 9 月 12 日
編集済み: Bruno Luong 2019 年 9 月 12 日
I have a convex hull, defined by
k=convhull(x,y)
P=[x(k),y(k)]
kS=polyshape(P)
kP=perimeter(kShape)
How can I divide the perimeter of the convex hull into n (e.g. 500) equal distance/lengths, and find the respective coordinates?

採用された回答

Bruno Luong
Bruno Luong 2019 年 9 月 12 日
編集済み: Bruno Luong 2019 年 9 月 12 日
% test data
xy=rand(100,2);
P=xy(convhull(xy),:);
d=[0;cumsum(sqrt(sum(diff(P).^2,2)))];
xyi=interp1(d,P,linspace(0,d(end),501)); % first point ~= last point
plot(P(:,1),P(:,2),'or',xyi(:,1),xyi(:,2),'b.-');

その他の回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2019 年 9 月 12 日
Perhaps this function is overkill, but to me it seems as if this FEX-contribution should help:
xy2sn, I don't know if it is the functionality of xy2sn or the sn2xy that most resembles your request.
Perhaps either of these contributions solves your problem better:
arclength, interparc. But one of these should get you at least 90% of the way.
HTH

カテゴリ

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