当前位置: 首页>>代码示例>>C++>>正文


C++ Triangulation::nearest_vertex方法代码示例

本文整理汇总了C++中Triangulation::nearest_vertex方法的典型用法代码示例。如果您正苦于以下问题:C++ Triangulation::nearest_vertex方法的具体用法?C++ Triangulation::nearest_vertex怎么用?C++ Triangulation::nearest_vertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Triangulation的用法示例。


在下文中一共展示了Triangulation::nearest_vertex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
    cout<<fixed<<setprecision(0);
    while(true)
    {
        int n;
        cin>>n;
        if (n==0) break;

        vector<Point> points;
        for (int i=0; i<n; i++)
        {
            long x,y;
            cin>>x>>y;
            points.push_back(Point(x,y));
        }

        Triangulation DT;
        DT.insert(points.begin(),points.end());

        int m;
        cin>>m;
        vector<Point> newp;
        //double  min = -1;
        for (int i=0; i<m; i++)
        {
            long x,y;
            cin>>x>>y;
            Point np(x,y);
            newp.push_back(np);
        }

        vector<double> sol;
        for (int i=0; i<m; i++)
        {
            Point np = newp[i];
            Point p = DT.nearest_vertex(np)->point();

            double dist = CGAL::to_double(squared_distance(np,p));
            sol.push_back(dist);

        }

        for (int i=0; i<m; i++) cout<<sol[i]<<endl;



    }
    return 0;
}
开发者ID:MohitYnwa,项目名称:ETH-Algo-Lab,代码行数:50,代码来源:bistros.cpp

示例2: main

int main() {
  // some basic setup stuff
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cout << fixed << setprecision(0);

  while(true) {
      int existing_count;
      cin >> existing_count;

      // kill switch for application
      if(existing_count == 0) {
        break;
      }

      // collect existing restaurants
      vector<K::Point_2> existing_locs;
      existing_locs.reserve(existing_count);

      for(int i=0; i < existing_count; i++) {
        double loc_x, loc_y;
        cin >> loc_x >> loc_y;

        existing_locs.push_back(K::Point_2(loc_x, loc_y));
      }

      // cosntruct triangulation
      Triangulation triang;
      triang.insert(existing_locs.begin(), existing_locs.end());

      // go through possible location
      int possible_count;
      cin >> possible_count;

      for(int i = 0; i < possible_count; i++) {
        int possible_x, possible_y;
        cin >> possible_x >> possible_y;
        
        K::Point_2 possible_point = K::Point_2(possible_x, possible_y);

        // find nearest vertex and by that the nearest point
        K::Point_2 nearest = triang.nearest_vertex(possible_point)->point();
        cout << CGAL::to_double(CGAL::squared_distance(nearest, possible_point)) << endl;
      }
    }
}
开发者ID:evelinad,项目名称:eth-algolab,代码行数:46,代码来源:main.cpp

示例3: testcase

void testcase(int n) {
	vector<K::Point_2> delaunay_vertices;
	for(int i = 0; i < n; ++i) {
		K::Point_2 p; cin >> p;
		delaunay_vertices.push_back(p);
	}

	Triangulation t;
	t.insert(delaunay_vertices.begin(), delaunay_vertices.end());

	int points; cin >> points;
	for(int i = 0; i < points; ++i) {
		K::Point_2 p; cin >> p;
		Triangulation::Vertex_handle v = t.nearest_vertex(p);
		K::Point_2 vp = v->point();
		K::FT distance = CGAL::squared_distance(p, vp);
		cout << floor_to_double(distance) << "\n";
	}
}
开发者ID:bengro,项目名称:AlgoLab13,代码行数:19,代码来源:Bistro1.cpp

示例4: remove_blue_point

 	void remove_blue_point(Point p){
        	blue_points.erase(std::remove(blue_points.begin(), blue_points.end(), p), blue_points.end());
		blue_red_t.remove(blue_red_t.nearest_vertex(p));
	}
开发者ID:martin-mfg,项目名称:voronoi-thesis-tester,代码行数:4,代码来源:problem.cpp


注:本文中的Triangulation::nearest_vertex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。