How to sort points clockwise or counterclockwise?

20 vues (au cours des 30 derniers jours)
youssef hany
youssef hany le 15 Sep 2022
Commenté : youssef hany le 15 Sep 2022
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 commentaire
Matt J
Matt J le 15 Sep 2022
Do you intend to fit a rectangle to these points? Otherwise, they don't form a clear polygon.

Connectez-vous pour commenter.

Réponses (1)

John D'Errico
John D'Errico le 15 Sep 2022
Modifié(e) : John D'Errico le 15 Sep 2022
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 commentaire
youssef hany
youssef hany le 15 Sep 2022
which one is clockwise increasing or decreasing sorting?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by