How to sort points clockwise or counterclockwise?

조회 수: 20 (최근 30일)
youssef hany
youssef hany 2022년 9월 15일
댓글: youssef hany 2022년 9월 15일
I'm using inpolygon function and it requires points to be sorted clockwise and sometimes counterclockwise, how I can do that about the mean point?!
I've attached the data, and here is a link for inpolygon function: https://www.mathworks.com/help/matlab/ref/inpolygon.html
  댓글 수: 1
Matt J
Matt J 2022년 9월 15일
Do you intend to fit a rectangle to these points? Otherwise, they don't form a clear polygon.

댓글을 달려면 로그인하십시오.

답변 (1개)

John D'Errico
John D'Errico 2022년 9월 15일
편집: John D'Errico 2022년 9월 15일
Can you compute the polar coordinates angle, around that mean? (Hint: use atan2. Don't forget to subtract off the mean FIRST.)
Can you now use sort? (Yes.) A clockwise sort just implies DECREASING order of the polar angle? An increasing sort would be a clockwise rotation.
  댓글 수: 1
youssef hany
youssef hany 2022년 9월 15일
which one is clockwise increasing or decreasing sorting?

댓글을 달려면 로그인하십시오.

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by