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


C++ Polygon2::begin方法代码示例

本文整理汇总了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;
}
开发者ID:ordovician,项目名称:LusionEngine,代码行数:19,代码来源:Line2.cpp

示例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;
}
开发者ID:ordovician,项目名称:LusionEngine,代码行数:41,代码来源:Graph2.cpp

示例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;
}
开发者ID:ordovician,项目名称:LusionEngine,代码行数:24,代码来源:Line2.cpp


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