本文整理汇总了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;
}
示例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;
}
}
}
示例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";
}
}
示例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));
}