Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Geometry 维护围绕中心点的点列表,保持CCW顺序_Geometry_Computational Geometry - Fatal编程技术网

Geometry 维护围绕中心点的点列表,保持CCW顺序

Geometry 维护围绕中心点的点列表,保持CCW顺序,geometry,computational-geometry,Geometry,Computational Geometry,我有以下课程: public class Vertex() { private double xCoord; private double yCoord; private ArrayList<Vertex> neighborList(); } 公共类顶点(){ 私人双xCoord; 私人双yCoord; private ArrayList neightrlist(); } 我想支持向邻域列表中添加/删除顶点,这样点就可以围绕该顶点按逆时针顺序列出(列表

我有以下课程:

 public class Vertex() {
    private double xCoord;
    private double yCoord;
    private ArrayList<Vertex> neighborList();
 }
公共类顶点(){
私人双xCoord;
私人双yCoord;
private ArrayList neightrlist();
}
我想支持向邻域列表中添加/删除顶点,这样点就可以围绕该顶点按逆时针顺序列出(列表中的第一个点无关紧要)。如果点是共线的,则应首先选择离此点较近的点。我尝试过几种方法,但到目前为止,我总能找到一个对给定方法不起作用的反例


有人知道如何以简单有效的方式进行此操作吗?

以极坐标形式表示点坐标

t = atan2(Y-Yo, X-Xo)
r = sqrt((X-Xo)^2 + (Y-Yo)^2)

并在角度和半径上使用字典顺序。

以极坐标形式表示点坐标

t = atan2(Y-Yo, X-Xo)
r = sqrt((X-Xo)^2 + (Y-Yo)^2)

在角度和半径上使用字典顺序。

此外,因为我们只比较距离,所以不需要做sqrt。此外,因为我们只比较距离,所以不需要做sqrt。