点集排序(快速排序)

您所在的位置:网站首页 角度的大小怎么排列 点集排序(快速排序)

点集排序(快速排序)

2024-07-10 01:23| 来源: 网络整理| 查看: 265

       点集排序算法,首先是要定义单个点如何确定大小,它不像数字那样是一维的,点是一个二维,所以在定义点的时候要定义点如何比较大小。

       点的大小一般来说,都是从左到右,从下到上的一个顺序,也就是说首先比较X方向,然后再比较Y方向。下面是我自己定义的一个点的类:

class DoxPoint2d { public:

    float _x, _y;

    /* @接口 默认构造函数      * @邮箱 [email protected]      * @时间 2018年11月12号      */     DoxPoint2d();

    /* @接口 默认析构函数      * @邮箱 [email protected]      * @时间 2018年11月12号      */     ~DoxPoint2d();

    /* @接口 默认构造函数      * @邮箱 [email protected]      * @时间 2018年11月12号      */     DoxPoint2d(float, float);

    /* @接口       * @返回 bool 成功返回值为true,否则返回值为false      * @邮箱 [email protected]      * @时间 2018年11月12号      */     DoxPoint3d toPoint3d() const;

    /* @接口 默认构造函数      * @邮箱 [email protected]      * @时间 2018年11月12号      */     DoxPoint2d(const DoxPoint2d &);          /* @接口 默认构造函数      * @邮箱 [email protected]      * @时间 2018年11月12号      */     DoxPoint2d(const DoxPoint3d &);

    /* @接口      * @参数       * @返回 r0:两矢量夹角为钝角      * @邮箱 [email protected]      * @时间 2019年5月21号      */     inline double dot(const DoxPoint2d &);

    /* @接口      * @参数      * @邮箱 [email protected]      * @时间 2019年5月22号      */     inline DoxPoint2d &operator+=(double);

    /* @接口      * @参数      * @邮箱 [email protected]      * @时间 2019年5月22号      */     inline DoxPoint2d &operator-=(double);

    /* @接口      * @参数       * @邮箱 [email protected]      * @时间 2019年5月22号      */     inline DoxPoint2d &operator*=(double);

    /* @接口      * @参数       * @邮箱 [email protected]      * @时间 2019年5月22号      */     inline DoxPoint2d &operator/=(double);

    /* @接口      * @返回 r>0:ep在矢量opsp的逆时针方向;              r=0:opspep三点共线;              r=(const DoxPoint2d &) const;

    /* @接口       * @返回 bool 成功返回值为true,否则返回值为false      * @邮箱 [email protected]      * @时间 2019年5月21号      */     inline bool operator= right) return;         int sidx = left, eidx = right;         DoxPoint2d pt = node[sidx];         while(sidx != eidx)         {             while(node[eidx] >= pt && sidx < eidx) eidx--;             while(node[sidx]



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3