• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ cg类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cg的典型用法代码示例。如果您正苦于以下问题:C++ cg类的具体用法?C++ cg怎么用?C++ cg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: TEST

TEST(Triangulation, one_line)
{
    using cg::point_2;
    std::vector<point_2> pts = boost::assign::list_of(point_2(0, 0))
                                                     (point_2(10, 0))
                                                     (point_2(20, 0))
                                                     (point_2(10, -10));

    cg::cell<double> cell;
    for (int i = 0; i < pts.size(); i++) {
        auto ans = cell.get_triangulation();

        for (const cg::triangle_2 & tr : ans) {
            std::cout << tr[0] << tr[1] << tr[2] << std::endl;
        }
        cell.add_point(pts[i]);
    }
    std::cout << "Ans" << std::endl;
    auto ans = cell.get_triangulation();

    for (const cg::triangle_2 & tr : ans) {
        std::cout << tr[0] << tr[1] << tr[2] << std::endl;
    }
    EXPECT_TRUE(true == true);
}
开发者ID:watson94,项目名称:cg,代码行数:25,代码来源:Delaunay_triangulation.cpp


示例2: TEST

TEST(convex_hull, simple_andrew4)
{
   using cg::point_2;

   std::vector<point_2> pts = boost::assign::list_of(point_2(1, 0))
                                                    (point_2(0, 1));

   EXPECT_TRUE(is_convex_hull(pts.begin(), cg::andrew_hull(pts.begin(), pts.end()), pts.end()));
}
开发者ID:free0u,项目名称:cg,代码行数:9,代码来源:convex_hull.cpp


示例3: TEST

TEST(orientation, counterclockwise2)
{
   using cg::point_2;

   std::vector<point_2> a = boost::assign::list_of(point_2(1, 0))
                                                  (point_2(3, 0))
                                                  (point_2(0, 2));

   EXPECT_TRUE(cg::counterclockwise(cg::contour_2(a)));
}
开发者ID:ChShersh,项目名称:cg,代码行数:10,代码来源:orientation.cpp


示例4: TEST

TEST(dynamic_convex_hull, without_deleting4)
{
   using cg::point_2;

   std::vector<point_2> pts = boost::assign::list_of(point_2(92.5535, 63.9831))
                              (point_2(48.2666, -2.07253))
                              (point_2(-87.6796, 74.2083))
                              (point_2(-41.6394, 42.1274))
                              (point_2(4.02735, 3.24309));

   cg::dynamic_hull dh;

   for (point_2 p : pts)
   {
      dh.add_point(p);
   }

   EXPECT_TRUE(is_convex_hull(pts.begin(), pts.end(), dh.get_hull().first, dh.get_hull().second));
}
开发者ID:YakutovDmitriy,项目名称:cg,代码行数:19,代码来源:dynamic_convex_hull.cpp


示例5: TEST

TEST(contains, triangle_point)
{
   using cg::point_2;

   cg::triangle_2 t(point_2(0, 0), point_2(1, 1), point_2(2, 0));

   for (size_t l = 0; l != 3; ++l)
      EXPECT_TRUE(cg::contains(t, t[l]));

   EXPECT_TRUE(cg::contains(t, point_2(1, 0.5)));

   EXPECT_TRUE(cg::contains(t, point_2(1, 0)));
   EXPECT_TRUE(cg::contains(t, point_2(0.5, 0.5)));
   EXPECT_TRUE(cg::contains(t, point_2(1.5, 0.5)));

   EXPECT_FALSE(cg::contains(t, point_2(0, 1)));
   EXPECT_FALSE(cg::contains(t, point_2(2, 1)));
   EXPECT_FALSE(cg::contains(t, point_2(1, -1)));
}
开发者ID:Susak,项目名称:cg,代码行数:19,代码来源:contains.cpp


示例6: get_circumcircle

 circle_2 get_circumcircle(triangle_2 const &t) const
 {
     if (t[0] == t[1] && t[1] == t[2])
         return circle_2(t[0], 0);
     if (orientation(t[0], t[1], t[2]) == cg::CG_COLLINEAR)
     {
         auto minmax = std::minmax({t[0], t[1], t[2]});
         point_2 p1 = minmax.first;
         point_2 p2 = minmax.second;
         if (t[0] != t[1])
             p2 = t[1];
         else
             p2 = t[2];
         point_2 center = p1 + vector_2((p2.x - p1.x) / 2, (p2.y - p1.y) / 2);
         double radius = segment_2(p1, p2).length() / 2;
         return circle_2(center, radius);
     }
     double A1 = t[1].x - t[0].x;
     double B1 = t[1].y - t[0].y;
     double C1 = (t[1].x - t[0].x) * (t[1].x + t[0].x) / 2 + (t[1].y - t[0].y) * (t[1].y + t[0].y) / 2;
     double A2 = t[2].x - t[0].x;
     double B2 = t[2].y - t[0].y;
     double C2 = (t[2].x - t[0].x) * (t[2].x + t[0].x) / 2 + (t[2].y - t[0].y) * (t[2].y + t[0].y) / 2;
     point_2 center((C1 * B2 - C2 * B1) / (A1 * B2 - A2 * B1),
                    (A1 * C2 - A2 * C1) / (A1 * B2 - A2 * B1));
     double radius = segment_2(center, t[0]).length();
     return circle_2(center, radius);
 }
开发者ID:dmekhanikov,项目名称:cg,代码行数:28,代码来源:delaunay_triangulation.cpp


示例7: print

   void print(cg::visualization::printer_type & p) const
   {
      p.corner_stream() << "double-click to clear." << cg::visualization::endl
                        << "press mouse rbutton for add vertex (click to first point to complete contour)" << cg::visualization::endl
                        << "move vertex with rbutton" << cg::visualization::endl
                        << "eps:" << eps << cg::visualization::endl;


      for (size_t i = 0; i < points_.size(); ++i)
      {
         p.global_stream((point_2f)points_[i] + vector_2f(5, 0)) << i;
      }
   }
开发者ID:BigBot22,项目名称:cg,代码行数:13,代码来源:duglas_pecher.cpp


示例8: triangle_intersects_triangle_viewer

 triangle_intersects_triangle_viewer()
     : s_(point_2(-100, -100), point_2(50, 50), point_2(0, 50)),
      t_(point_2(-50, -50), point_2(50, -50), point_2(-50, 50)),
       rbutton_pressed_(false),
       int_({})
 {
     int_ = cg::intersection(s_, t_);
 }
开发者ID:dvbobrov,项目名称:cg,代码行数:8,代码来源:exam_2401_2.cpp


示例9: print

   void print(cg::visualization::printer_type & p) const
   {
      p.corner_stream() << "double-click to clear." << cg::visualization::endl
                        << "press mouse rbutton for add vertex (click to first point to complete contour)" << cg::visualization::endl
                        << "move vertex with rbutton" << cg::visualization::endl
                        << "yellow contour -- not ccw or convex" << cg::visualization::endl
                        << "green contour -- contains cursor" << cg::visualization::endl
                        << "red contour -- don't contains cursor" << cg::visualization::endl;

      for (size_t i = 0; i < points_.size(); ++i)
      {
         p.global_stream((point_2f)points_[i] + vector_2f(5, 0)) << i;
      }
   }
开发者ID:BigBot22,项目名称:cg,代码行数:14,代码来源:ccw_convex_contains_point.cpp


示例10: draw

   void draw(cg::visualization::drawer_type & drawer) const
   {
       for (size_t idx = 0; idx < cur_contour; idx++)
       {
           contour const & cont = conts[idx];
           drawer.set_color(Qt::red);
           if (cg::counterclockwise(cont))
              drawer.set_color(Qt::green);

           for (size_t i = 0; i < cont.size(); i++)
           {
              size_t j = (i + 1) % cont.size();
              cg::point_2 p1 = cont[i], p2 = cont[j];
              drawer.draw_line(p1, p2);
           }
       }
      if (in_building_)
      {
         drawer.set_color(Qt::white);

         for (size_t i = 1; i < conts[cur_contour].size(); ++i)
         {
            drawer.draw_line(conts[cur_contour][i - 1], conts[cur_contour][i]);
         }
      } else
      {
          drawer.set_color(Qt::blue);
          drawer.draw_point(center, 3);
          contour_2 result = minkowski_convex_sum(contour_2(conts[0]), contour_2(reversed));

          for (size_t i = 0; i < result.size(); ++i)
          {
              size_t j = (i + 1) % result.size();
             drawer.draw_line(result[i], result[j]);
          }
      }
   }
开发者ID:dmekhanikov,项目名称:cg,代码行数:37,代码来源:minkowski_sum.cpp


示例11:

 triangle_contains_point_viewer():
     t_(point_2(0, 0),
        point_2(100, 100),
        point_2(200, 0)),
     rbutton_pressed_(false)
 {
 }
开发者ID:suhain,项目名称:cg,代码行数:7,代码来源:triangle_contains_point.cpp


示例12: on_double_click

 bool on_double_click(const point_2f & p)
 {
    chain.clear();
    chain = {point_2(0, 0), point_2(20, 20), point_2(40, 40)};
    current_vertex_.reset();
    return true;
 }
开发者ID:BorysMinaiev,项目名称:cg,代码行数:7,代码来源:douglas.cpp


示例13: wheelEvent

void main_window_t::wheelEvent(QWheelEvent * e)
{
   double old_zoom = zoom_;

   int delta = e->delta() / 8 / 15;
   if (delta > 0)
   {
      for (int i = 0; i != delta; ++i)
         zoom_ *= 1.1;
   }
   else if (delta < 0)
   {
      for (int i = 0; i != delta; --i)
         zoom_ /= 1.1;
   }

   point_2f pos(e->pos().x(), e->pos().y());
   point_2f sz(size().width() / 2, size().height() / 2);

   vector_2f diff = pos - sz;

   center_ += (old_zoom - zoom_) * vector_2f(diff.x, -diff.y);
   center_ = limit(center_);

   e->accept();

   viewer_->on_move(limit(screen_to_global(e->pos())));

   resize_impl(size().width(), size().height());
   updateGL();
}
开发者ID:BigBot22,项目名称:cg,代码行数:31,代码来源:main_window.cpp


示例14: resize_impl

void main_window_t::resize_impl(int screen_w, int screen_h)
{
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();

   vector_2f size = (zoom_ / 2) * vector_2f(screen_w, screen_h);

   point_2f left_bottom = center_ + (-size);
   point_2f right_top   = center_ + size;

   glOrtho(left_bottom.x, right_top.x, left_bottom.y, right_top.y, -1.0, 1.0);
   glViewport(0, 0, screen_w, screen_h);
}
开发者ID:BigBot22,项目名称:cg,代码行数:13,代码来源:main_window.cpp


示例15: on_press

   bool on_press(const point_2f & p)
   {
      for (size_t i = 0; i < chain.size(); ++i)
      {
         if (fabs(chain[i].x - p.x) < 15 && fabs(chain[i].y - p.y) < 15)
         {
            current_vertex_ = i;
            return true;
         }
      }

      if(!current_vertex_)
         chain.push_back(point_2(p.x, p.y));

      return true;
   }
开发者ID:BorysMinaiev,项目名称:cg,代码行数:16,代码来源:douglas.cpp


示例16: calc_visibility_graph

 void calc_visibility_graph()
 {
     int n = 0;
     for (contour_2 &c : contours)
     {
         if (!counterclockwise(c))
         {
             c.reverse();
             std::reverse(points.begin() + n, points.begin() + n + c.size());
         }
         n += c.size();
     }
     graph g = visibility_graph(contours.begin(), contours.end(), true);
     visibility_segments.clear();
     for (int i = 0; i < (int) points.size(); ++i)
     {
         std::vector<int> const &edges = g.get_edges(i);
         for (int j : edges)
             visibility_segments.push_back(segment_2(points[i], points[j]));
     }
 }
开发者ID:dmekhanikov,项目名称:cg,代码行数:21,代码来源:visibility.cpp


示例17: new_contour

 void new_contour()
 {
     contours.push_back(contour_2(std::vector<point_2>()));
 }
开发者ID:dmekhanikov,项目名称:cg,代码行数:4,代码来源:navigation.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ channel类代码示例发布时间:2022-05-31
下一篇:
C++ cfdemCloud类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap