本文整理汇总了C++中Polygon2::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygon2::begin方法的具体用法?C++ Polygon2::begin怎么用?C++ Polygon2::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon2
的用法示例。
在下文中一共展示了Polygon2::begin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*!
Find number of times ray intersects polygon defined by iterators
*/
int Line2::noIntersections(const Polygon2& poly) const
{
int n = 0;
Vector2 v, v_prev;
Point2 p, p_prev;
ConstPointIterator2 begin = poly.begin();
ConstPointIterator2 end = poly.end();
ConstPointIterator2 it;
for (it = begin+1; it != end; ++it) {
if (intersect(Segment2(*(it-1), *it)))
++n;
}
if (intersect(Segment2(*(end-1), *begin)))
++n;
return n;
}
示例2: p
bool GraphImp2::shortestPath(Trapezoid2* source, Trapezoid2* target, Polygon2& path) const
{
assert(iGraph != 0);
assert(source != 0 && target != 0);
Graph& g = *iGraph;
// Find source and target vertex in graph
Vertex s = vertex(source->tag(), g);
Vertex t = vertex(target->tag(), g);
Vertices p(num_vertices(g)); // Predecessor map
Reals d(num_vertices(g)); // Distance map
// A* will find ALL shortest paths like Dijkstra so we need to throw exception when goal has been found
try {
astar_search(
g,
s,
DistanceHeuristic(iGraph, t),
weight_map(get(&EdgeProperty::weight, g)).
predecessor_map(make_iterator_property_map(p.begin(), get(vertex_index, g))).
distance_map(make_iterator_property_map(d.begin(), get(vertex_index, g))).
visitor(GoalVisitor(t))
);
}
catch (FoundGoalException e) {
Vertex t = vertex(target->tag(), g);
// Store coordinates of shortest path
while (t != p[t]) {
path.push_back(g[t]);
t = p[t];
}
path.push_back(g[t]);
reverse(path.begin(), path.end());
return true;
}
return false;
}
示例3: assert
/*!
Find closest intersection point on polygon
*/
bool Line2::intersection(const Polygon2& poly, Vector2& result) const
{
assert(false); // TODO: Think this is buggy. Why substact origin() from v and why no test on end to begin part
bool found_point = false;
Vector2 v, v_prev;
Point2 p, p_prev;
ConstPointIterator2 begin = poly.begin();
ConstPointIterator2 end = poly.end();
ConstPointIterator2 it;
for (it = begin+1; it != end; ++it) {
if (!intersection(Segment2(*(it-1), *it), p)) continue;
v = p - origin();
if (v.squaredLength() >= v_prev.squaredLength()) continue;
v_prev = v;
p_prev = p;
found_point = true;
}
result = p_prev;
return found_point;
}