Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.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
Algorithm 基于点绘制形状,确保线不';t交叉_Algorithm_Graphics - Fatal编程技术网

Algorithm 基于点绘制形状,确保线不';t交叉

Algorithm 基于点绘制形状,确保线不';t交叉,algorithm,graphics,Algorithm,Graphics,比如说,我得了100分,想画一个闭合曲线(我用C#和图形),像这样: Graphics g = this.CreateGraphics(); Pen pen = new Pen(Color.Black, 2); Point[] points = new Point[DrawingPoints]; for (int x = 0; x < DrawingPoints; x++) { int px = r.N

比如说,我得了100分,想画一个闭合曲线(我用C#和图形),像这样:

Graphics g = this.CreateGraphics();
        Pen pen = new Pen(Color.Black, 2);
        Point[] points = new Point[DrawingPoints];
        for (int x = 0; x < DrawingPoints; x++)
        {
            int px = r.Next(0, MaxXSize);
            int py = r.Next(0, MaxYSize);
            Point p = new Point(px, py);
            points[x] = p;
        }
        g.DrawClosedCurve(pen, points);
Graphics g=this.CreateGraphics();
钢笔=新钢笔(颜色:黑色,2);
点[]点=新点[绘图点];
对于(int x=0;x
这是连接点,因为他们进入点[],线交叉-你不会得到一个坚实的数字与此

有没有一种算法可以帮助我通过掷点数得到一个立体的图形?下面是一张图片(我尽了最大的努力呵呵)来帮助想象我的要求

好的,在O(n logn)时间内,你可以计算出点的质心,并按照围绕质心的角度对它们进行排序,留下一个星形多边形。这很有效,但可能会把你的分数顺序搞得太乱


我想你会对TSP的2-OPT方法(描述)的结果更满意。2-OPT是最糟糕的指数时间,但实际上是多项式时间。

比如说,一个不相交的新月形会发生什么?同样的问题重新表述-如果我有一个点数组,我如何“抛出”它们,如果它们按顺序连接,我将得到一个实心形状(线不相交)。@Per,真的没有什么,这只是一个正常的形状,就像其他形状一样。