为什么我不能在CGAL中添加点数
问题描述:
我想使用+
运算符在CGAL中添加两点。为什么我不能在CGAL中添加点数
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Point_2.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point;
using namespace std;
cout << Point(8.9, 9) + Point(1,1) << endl;
cout << Point(8.9, 9) + Point(2,2) * .5 << endl;
我认为这是可能的,考虑到documentation。
,但我得到了以下错误:
/path_to_file/main.cpp:25: error: no match for ‘operator+’ (operand types are ‘Point {aka CGAL::Point_2<CGAL::Simple_cartesian<double> >}’ and ‘Point {aka CGAL::Point_2<CGAL::Simple_cartesian<double> >}’)
cout << Point(8.9, 9) + Point(1,1) << endl;
~~~~~~~~~~~~~~^~~~~~~~~~~~
答
我被误读的文档。您只能将矢量添加到点。 (这使得完全意义上,当然)
从文档:
Point_2< Kernel > operator+ (const Point_2< Kernel > &p, const Vector_2< Kernel > &v) returns the point obtained by translating p by the vector v
你需要把你的'的std :: cout'statements一个函数内。也许'int main()'? – Galik
它在数学上不正确。使用'Vector_2'是有效的。 – sloriot
也许我错过了它,但是在文档中它说你可以添加两点?在数学上,这不应该被允许。 – templatetypedef