How to identify the relative location of points on a rectangle (or general polygon)?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Tommy
2020-3-30
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]
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!