Delaunay三角网

三角网生长法(课本上的方法按原意实现)

//控制台演示
#include 
#include 
#include 
#include 
#include 
#define PI 3.14159

struct POINT
{	
	double x;
	double y;
};
typedef POINT VECTOR;

struct SEGMENT
{
	POINT * p_begin;
	POINT * p_end;
	bool bExpandable;//记录边可否扩展
};

struct TRIANGLE
{
	POINT * vertex1;
	POINT * vertex2;
	POINT * vertex3;
};

//方便调试的功能
std::ostream & operator<<(std::ostream & os, const POINT & pt)
{
	os<<"("< "<<*seg.p_end;
	return os;
}
std::ostream & operator<<(std::ostream & os, const TRIANGLE & tri)
{
	os<<"△: "<<*tri.vertex1<<" , "<<*tri.vertex2<<" , "<<*tri.vertex3;
	return os;
}

int main()
{
	//数据来源于《空间分析》课本P205
	clock_t begin = clock();
	std::cout<<"数据来源于《空间分析》课本P205 采用内核生长算法"< segment_list;//边表
	std::vector triangle_list;//三角形表

	//最近两点
	auto GetDis = [] (const POINT & p1, const POINT & p2) ->double {return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));};
	double min_dis = GetDis(pts[0], pts[1]);
	int min_i = 0;
	int min_j = 1;
	for(int i = 0; i < size - 1; i++)
	{
		for(int j = i + 1; j < size; j++

你可能感兴趣的:(简单算法,GIS,STL,GIS,STL,C++)