How to sort points clockwise or counterclockwise?

17 ビュー (過去 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 Center および File ExchangeMatrices and Arrays についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by