Sorting list of two-dimensional coordinates by clockwise angle using Python?

前端 未结 3 1394
伪装坚强ぢ
伪装坚强ぢ 2021-01-31 12:56

I have a set of points with x and y coordinates that can be seen in the figure below. The coordinates of the 9 points were stored in a list as follows:

L = [[5,2         


        
3条回答
  •  北恋
    北恋 (楼主)
    2021-01-31 13:21

    Sorting by angle is not enough
    We should sort points lexicographicallly by polar angle and distance from origin
    We sort by polar angle and in case of a tie we sort by a distance from origin

提交回复
热议问题