Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Circle-Circle-intersection

Subject: CGAL users discussion list

List archive

[cgal-discuss] Circle-Circle-intersection


Chronological Thread 
  • From: Sybren A. Stüvel <>
  • To:
  • Subject: [cgal-discuss] Circle-Circle-intersection
  • Date: Tue, 23 Apr 2013 14:58:56 +0800

Dear list,

As part of a (for this mailing list not that interesting) algorhtm, I have to determine whether two circles intersect. I do this using CGAL::do_intersect(...) as described on http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Kernel_23_ref/Function_do_intersect.html

Now I believe that there either is a bug in the implementation, or in the documentation, as my interpretation of the latter does not correspond to the behaviour of the former. The documentation states that:

    for objects like triangles and polygons that enclose a bounded region, this region is part of the object.

This led me to believe that for circles, which also enclose a bounded region, this would also apply. I therefore assumed that when one circle is embedded in the other (i.e. their boundaries do not intersect), CGAL::do_intersect(...) would return true. After all, the bounded regions do intersect. However, CGAL behaves differently, and performs the intersection test on the boundary alone. I have attached a test program that shows this behaviour.

Tested on CGAL 4.1, Windows 8 64-bit, Visual Studio 2010.

I fully understand that a circle is not a disc, and that the behaviour of CGAL::do_intersect is perfectly defendable. However, a change in the documentation may be a good idea. It would have saved me a few days of debugging my code.


Kind regards,
--
Sybren A. Stüvel

http://stuvel.eu/

#include <CGAL/Point_2.h>
#include <CGAL/Circle_2.h>
#include <CGAL/Cartesian.h>
#include <iostream>

typedef CGAL::Cartesian<double>  K;
typedef CGAL::Circle_2<K>        Circle_2;
typedef CGAL::Point_2<K>         Point_2;

int main(void)
{
    Circle_2 inner(Point_2(0, 0), 1);
    Circle_2 outer(Point_2(0, 0), 4);
    
    if (CGAL::do_intersect(inner, outer)) {
        std::cout << "Circles intersect" << std::endl;
    } else {
        std::cout << "Circles do not intersect" << std::endl;
    }

    return 0;
}



Archive powered by MHonArc 2.6.18.

Top of Page