2017-10-11 15 views
-1

J'essaie d'ajouter deux points dans CGAL en utilisant l'opérateur +.Pourquoi ne puis-je pas ajouter de points dans 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; 

que je suppose être possible compte tenu de la documentation.

Mais je reçois l'erreur suivante:

/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; 
     ~~~~~~~~~~~~~~^~~~~~~~~~~~ 
+0

Vous devez mettre votre 'std :: cout'statements dans une fonction. peut-être 'int main()'? – Galik

+1

Ce n'est pas mathématiquement correct. Avec 'Vector_2' est-il valide. – sloriot

+0

Peut-être que je l'ai manqué, mais où dans la documentation dit-on que vous pouvez ajouter deux points? Mathématiquement, cela ne devrait pas être autorisé. – templatetypedef

Répondre

0

j'interprète mal la documentation. Vous pouvez uniquement ajouter des vecteurs aux points. (Ce qui est logique tout à fait, bien sûr)

De la documentation:

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