本文整理汇总了C++中cg::point_2方法的典型用法代码示例。如果您正苦于以下问题:C++ cg::point_2方法的具体用法?C++ cg::point_2怎么用?C++ cg::point_2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cg
的用法示例。
在下文中一共展示了cg::point_2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2:
triangle_contains_point_viewer():
t_(point_2(0, 0),
point_2(100, 100),
point_2(200, 0)),
rbutton_pressed_(false)
{
}
示例3: 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);
}
示例4: 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()));
}
示例5: 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)));
}
示例6: 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)));
}
示例7: TEST
TEST(dynamic_convex_hull, without_deleting3)
{
using cg::point_2;
std::vector<point_2> pts = boost::assign::list_of(point_2(-15.2939, -91.2349))
(point_2(73.6514, -84.1031))
(point_2(46.0487, -42.9297))
(point_2(21.95, 48.3017))
(point_2(-6.31702, -43.6781));
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));
}
示例8:
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_);
}
示例9: 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;
}
示例10: TEST
TEST(minkowski, square)
{
using cg::point_2;
std::vector<point_2> a = boost::assign::list_of(point_2(0, 0))
(point_2(4, 0))
(point_2(4, 4))
(point_2(0, 4));
std::vector<point_2> b = boost::assign::list_of(point_2(-2, -2))
(point_2(2, -2))
(point_2(2, 2))
(point_2(-2, 2));
std::vector<point_2> c = boost::assign::list_of(point_2(-2, -2))
(point_2(6, -2))
(point_2(6, 6))
(point_2(-2, 6));
auto ans = cg::contour_2(c);
auto res = cg::minkowski_sum(cg::contour_2(a), cg::contour_2(b));
EXPECT_TRUE( std::equal(ans.begin(), ans.end(), res.begin()) );
}
示例11: TEST
#include <gtest/gtest.h>
#include <boost/assign/list_of.hpp>
#include <cg/operations/convex.h>
#include <cg/convex_hull/graham.h>
#include <misc/random_utils.h>
#include "random_utils.h"
using namespace util;
TEST(convex, 1)
{
using cg::point_2;
std::vector<point_2> pts = boost::assign::list_of(point_2(0, 0));
EXPECT_TRUE(cg::convex(cg::contour_2(pts)));
}
TEST(convex, 2)
{
using cg::point_2;
std::vector<point_2> pts = boost::assign::list_of(point_2(0, 0))
(point_2(1, 0));
EXPECT_TRUE(cg::convex(cg::contour_2(pts)));
}
TEST(convex, 3)
示例12: chain
contour_contains_point_viewer()
: chain(std::vector<point_2>({point_2(0, 0), point_2(20, 20), point_2(40, 40)}))
, eps(0.5)
, rbutton_pressed_(false)
{}
示例13:
rectangle_intersects_segment_viewer()
: s_(point_2(-100, -100), point_2(100, 100)),
r_(cg::range_d(-50, 50), cg::range_d(-50, 50)),
rbutton_pressed_(false)
{}
示例14: contour
contour_contains_point_viewer()
: contour(std::vector<point_2>({point_2(0, 0), point_2(100, 100), point_2(200, 0)}))
{}
示例15: DCEL
localization_point_viewer()
{
dcel_by_lines = new DCEL(point_2(-400, -400), point_2(400, 400));
}