Is there a function to turn ?x2 matrix of coordinates of vertices of a polygon into a ?x4 matrix of coordinates of line segments of that polygon?
1 次查看(过去 30 天)
显示 更早的评论
Is there a function to turn a matrix of vertices of a polygon like this [2, 4; 5, 6; 6, 6; 8,5] into a matrix of line segments of that polygon like this [2, 4, 5, 6; 5, 6, 6, 6; 6, 6, 8, 5; 8, 5, 2, 4]?
0 个评论
采纳的回答
Stephan
2019-12-4
Yes,
circshift will do the job:
A = [2, 4; 5, 6; 6, 6; 8,5]
B = [2, 4, 5, 6; 5, 6, 6, 6; 6, 6, 8, 5; 8, 5, 2, 4]
% The solution:
C = [A circshift(A,-1)]
% The test:
A =
2 4
5 6
6 6
8 5
B =
2 4 5 6
5 6 6 6
6 6 8 5
8 5 2 4
C =
2 4 5 6
5 6 6 6
6 6 8 5
8 5 2 4
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Elementary Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!