필터 지우기
필터 지우기

How to identify the relative location of points on a rectangle (or general polygon)?

조회 수: 1 (최근 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
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개)

mark palmer
mark palmer 2020년 3월 30일
편집: mark palmer 2020년 3월 30일
Any quadrilateral, yes, or any 8, 12 or 16 etc point shape. For a diamond, it would be TL BL BR TR. The other solution to a diamond is also fine, makes no difference.

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by