struct POINT{
POINT(double x, double y) :x(x),y(y){}
POINT(){}
typedef double coordinate;
coordinate x = 0;
coordinate y = 0;
double distance=0;
double cosine=1;
};
ostream& operator<<(ostream& os,POINT p){
os << "(" << p.x << ',' << p.y << ")" << std::ends;
return os;
}
bool compareX(Dnode<POINT>*left, Dnode<POINT>*right){
return left->data.x > right->data.x;
}
bool compareY(Dnode<POINT>*left, Dnode<POINT>*right){
return left->data.y > right->data.y;
}
bool compareD(Dnode<POINT>*left, Dnode<POINT>*right){
return left->data.distance > right->data.distance;
}
bool compareC(Dnode<POINT>*left, Dnode<POINT>*right){
return left->data.cosine < right->data.cosine;
}
class CONVEX_POLYGON
{
public:
typedef doublyCircularList<POINT> list;
CONVEX_POLYGON(){}
CONVEX
印度阿三数据结构——链表——凸包
最新推荐文章于 2024-02-27 14:16:39 发布
本文介绍了一种使用链表实现凸包的算法。定义了包含点坐标、距离和余弦值的POINT结构体,并提供了比较点的x、y坐标、距离和余弦值的比较函数。接着,定义了一个名为CONVEX_POLYGON的类,用于存储点的链表并提供构造函数、输出和排序方法。最后,通过sort()方法,实现了对点的x、y坐标、距离和余弦值的排序,从而找到凸包。
摘要由CSDN通过智能技术生成