Sorting a List of 3d coplanar points to be clockwise or counterclockwise

后端 未结 1 1680
我寻月下人不归
我寻月下人不归 2020-12-08 12:05

I have a list of 3D points. I know they are all coplanar. I have the center that I want to sort them around and the normal to the plane on which the points and the center li

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 12:33

    There's no need to convert everything to 2D.

    You have the center C and the normal n. To determine whether point B is clockwise or counterclockwise from point A, calculate dot(n, cross(A-C, B-C)). If the result is positive, B is counterclockwise from A; if it's negative, B is clockwise from A.

    0 讨论(0)
提交回复
热议问题