필터 지우기
필터 지우기

Identifying elements of an array in clockwise order

조회 수: 2 (최근 30일)
Sean
Sean 2014년 7월 7일
댓글: Sean 2014년 7월 8일
If I have an array A such that it contains vertex coordinates of polygons where
A=[ 1 1;
2 0;
4 0;
10 1;
0 0;
1 5;
11 2;
0 2;
2 2;
.
.
.
x y ]
and C such that it contains the collection of vertex locations in A of a polygon where C is something like:
C = {[ 2, 5, 8, 9]
.
.
.
[x,y locations in A]}
C{1} contains the coordinates (2,0), (0,0), (0,2), and (2,2) from A. I want to take say, the first elements of C{1}, and sort C such that the remaining element order in C{1} moves clockwise (or counter-clockwise) in terms of element location with respect to polygon generation. So C{1}(1)=2 (2,0), and the remaining elements would follow as such:
C{1}(2)=9 (2,2)
C{1}(3)=8 (0,2)
C{1}(4)=5 (0,0)
  댓글 수: 6
Sean
Sean 2014년 7월 7일
That is clever, cheers.
Sean
Sean 2014년 7월 8일
For future reference, something like this
v = cell(size(C));
for j=1:length(C)
frodo = C{j};
aragorn_x = new_pts(frodo,1);
aragorn_y = new_pts(frodo,2);
DT = delaunayTriangulation(aragorn_x,aragorn_y);
[K,v{j}] = convexHull(DT);
end
turned out to be valuable (with the help of Jos (10584)).

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by