CGAL 交集 returns 错误结果
CGAL Intersection returns false result
我对 CGAL::do_intersect
的工作原理有点困惑。
我认为函数 returns true
如果两个多边形中都有一个点。据我所知,in
位于 out
内,我应该看到 true
打印出来或者我错过了什么?
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
int main(int argc, char **argv)
{
Polygon_2 in, out;
in.push_back(Point_2(1,1));
in.push_back(Point_2(1,2));
in.push_back(Point_2(2,2));
in.push_back(Point_2(2,1));
out.push_back(Point_2(0,0));
out.push_back(Point_2(3,0));
out.push_back(Point_2(3,3));
out.push_back(Point_2(0,3));
std::cout << "IN intersect with OUT is " << (CGAL::do_intersect(in, out) ? "true":"false") << std::endl;
std::cout << "OUT intersect with IN is " << (CGAL::do_intersect(out, in) ? "true":"false") << std::endl;
std::cout.flush();
}
多边形的顶点需要逆时针旋转。以下代码产生所需的输出:
IN intersect with OUT is true
OUT intersect with IN is true
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
int main(int argc, char **argv)
{
Polygon_2 in, out;
in.push_back(Point_2(1,1));
in.push_back(Point_2(2,1));
in.push_back(Point_2(2,2));
in.push_back(Point_2(1,2));
out.push_back(Point_2(0,0));
out.push_back(Point_2(3,0));
out.push_back(Point_2(3,3));
out.push_back(Point_2(0,3));
std::cout << "IN intersect with OUT is " << (CGAL::do_intersect(in, out) ? "true":"false") << std::endl;
std::cout << "OUT intersect with IN is " << (CGAL::do_intersect(out, in) ? "true":"false") << std::endl;
std::cout.flush();
}
我对 CGAL::do_intersect
的工作原理有点困惑。
我认为函数 returns true
如果两个多边形中都有一个点。据我所知,in
位于 out
内,我应该看到 true
打印出来或者我错过了什么?
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
int main(int argc, char **argv)
{
Polygon_2 in, out;
in.push_back(Point_2(1,1));
in.push_back(Point_2(1,2));
in.push_back(Point_2(2,2));
in.push_back(Point_2(2,1));
out.push_back(Point_2(0,0));
out.push_back(Point_2(3,0));
out.push_back(Point_2(3,3));
out.push_back(Point_2(0,3));
std::cout << "IN intersect with OUT is " << (CGAL::do_intersect(in, out) ? "true":"false") << std::endl;
std::cout << "OUT intersect with IN is " << (CGAL::do_intersect(out, in) ? "true":"false") << std::endl;
std::cout.flush();
}
多边形的顶点需要逆时针旋转。以下代码产生所需的输出:
IN intersect with OUT is true
OUT intersect with IN is true
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
int main(int argc, char **argv)
{
Polygon_2 in, out;
in.push_back(Point_2(1,1));
in.push_back(Point_2(2,1));
in.push_back(Point_2(2,2));
in.push_back(Point_2(1,2));
out.push_back(Point_2(0,0));
out.push_back(Point_2(3,0));
out.push_back(Point_2(3,3));
out.push_back(Point_2(0,3));
std::cout << "IN intersect with OUT is " << (CGAL::do_intersect(in, out) ? "true":"false") << std::endl;
std::cout << "OUT intersect with IN is " << (CGAL::do_intersect(out, in) ? "true":"false") << std::endl;
std::cout.flush();
}