How to identify the relative location of points on a rectangle (or general polygon)?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
This is more of a mental challenge that a programming one, but I have drawn a polygon with insertShape and I want to be able to identify the top left, top right, bottom left and bottom right points (TL TR BL BR) for any 4 points of a rectangle. For instance, the points
[1 3; 2 5; 4 6; 3 4]
has TL, TR, BR, BL in that order, given that we read the full image size with 1 1 as top left and 6,6 as bottom right.
Example 2:
[2 2; 4 3; 5 2; 4 3; 3 1]
has TR BR BL TL
The order of the points between the brackets can begin with any point and end with any point, so the answer above should give the same corespondance between points and positions if the order of the points was differently arranged. In other words,
[4 3; 5 2; 4 3; 3 1; 2 2]
has BR BL TL TR, same as above.
If I could generalize this to the points of any size polygon that would be great, but I'm mainly after a solution for a rectangle.
Thanks!
1 comentario
Tommy
el 30 de Mzo. de 2020
Do you mean any quadrilateral? And what should happen in the case of a diamond? e.g. [2 2; 3 3; 2 4; 1 3]
Respuestas (1)
Ver también
Categorías
Más información sobre Image Segmentation and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!