How to get the diagonal point pairs of a 2D rectangle?

조회 수: 6 (최근 30일)
wei zhang
wei zhang 2020년 7월 13일
답변: Shubham Shukla 2020년 7월 13일
I am trying to find the diagonal point pair of an arbitrary input rectangle. i.e.
A = [1,1];
B = [-1,-1];
C = [1,-1];
D = [-1,1];
The expected output should be (A,B) and (C,D). The rectangle should be A,D,B,C in counterclockwise. Is there any function in Matlab could do it? I had tried ispolycw. But it only care the clockwise, not the diagonal. Any suggestion would be appreciated.

채택된 답변

Shubham Shukla
Shubham Shukla 2020년 7월 13일
A & B are diagonal points if both the coordinates of A and B differ, provided that the rectangle has non-zero width and height.
A = [x1, y1], B = [x2, y2]
if x1 ~= x2 and y1~=y2
" A and B are diagonal Pair"
Do this for all point pairs.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by