Skip to Content.
Sympa Menu

cgal-discuss - Problem with point collinearity

Subject: CGAL users discussion list

List archive

Problem with point collinearity


Chronological Thread 
  • From:
  • To:
  • Subject: Problem with point collinearity
  • Date: Fri, 15 Jun 2007 00:50:43 +0200

Hi all,

This should be a very easy question.

When I check if the points (0.14, 0.22), (0.15, 0.21) and (0.19,0.17) are
collinear, using CGAL::collinear, it returns “CGAL_LEFT”, which is false,
because those points are in fact collinear.

However, if I do the same with the points (14, 22), (15, 21) and (19, 17) I
get the correct answer: “CGAL_COLLINEAR”.

My code is:


#include "bso_rational_nt.h"

#include <CGAL/Cartesian.h>
#include <CGAL/predicates_on_points_2.h>

//#include <CGAL/Exact_predicates_exact_constructions_kernel.h>

#include<stdio.h>

//typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
//typedef Kernel::Point_2 Point;

typedef CGAL::Cartesian<Number_type> K;
typedef CGAL::Point_2<K> Point;


int main()
{

//line y=-x+36
switch (CGAL::orientation(Point(14,22),Point(15,21),Point(19,17))){
case CGAL::LEFT_TURN:
std::cout << "Left" << std::endl;
break;
case CGAL::RIGHT_TURN:
std::cout << "Right" << std::endl;
break;
case CGAL::COLLINEAR:
std::cout << "Collinear" << std::endl;
break;
};

//line y=-x+0.36
switch
(CGAL::orientation(Point(0.14,0.22),Point(0.15,0.21),Point(0.19,0.17))){
case CGAL::LEFT_TURN:
std::cout << "Left" << std::endl;
break;
case CGAL::RIGHT_TURN:
std::cout << "Right" << std::endl;
break;
case CGAL::COLLINEAR:
std::cout << "Collinear" << std::endl;
break;
};

}


(The <bso_rational_nt.h> is the file that is in the folder "C:\Program
Files\CGAL-3.2.1\examples\Boolean_set_operations_2".)

I already tried to use the CGAL::Exact_predicates_exact_constructions_kernel
(as you can check above), but the problem remains.

This problem, in fact, happens with other points, however this is a simple
example.

Anyone have any ideia of what is wrong??

I am using CGAL 3.2.1 and Microsoft Visual Studio 2005.

I really don’t know what is happening. Anyone can help me?

Thanks,
Mafalda



Archive powered by MHonArc 2.6.16.

Top of Page