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 visualización (últimos 30 días)
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]?

Respuesta aceptada

Stephan
Stephan el 4 de Dic. de 2019
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

Más respuestas (0)

Categorías

Más información sobre Elementary Polygons en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by