1

I am working on a motion planning problem and I'm facing problems with numeric precision.

My goal is to divide the two-dimensional vector space of real numbers with segments and circular arcs. The 2D Arrangement of the CGAL library is well indicated for this purpose. Here are the types I have defined:

typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::Arr_conic_traits_2<Rat_kernel, Alg_kernel, Nt_traits> Conic_traits_2;
typedef CGAL::Arrangement_2<Conic_traits_2> Arrangement_2;

During the computation I need to displaced a segment whose endpoints have rational coordinates, (due to the length of the segment, i.e. square root,) the image of this segment then have algebraic coordinates. I also need to add two circular arcs to the endpoints of this image.

All I have found in the manual is a way to add circular arcs with rational coordinates for the center, how to treat those with algebraic coordinates (without precision error) ?

Thanks.

lrineau
  • 6,036
  • 3
  • 34
  • 47
Flabetvibes
  • 3,066
  • 20
  • 32

2 Answers2

3

The most efficient way to subdivide the plane with linear segments and circular arcs exploiting CGAL arrangements is to use the CGAL::Arr_circle_segment_traits_2 traits. As the manual says, it should be instantiated with a rational kernel (a kernel defined with an exact rational number type). However, the Point_2 type nested in the traits class is different than the Kernel::Point_2 type. Its coordinates are an instantiation of CGAL::Sqrt_extension. This special number type is much more efficient than a standard algebraic number type. If you must use a (standard) algebraic number type for some reason, then you can use the CGAL::Arr_algebraic_segment_traits_2 traits. The latter supports any general algebraic curve.

lrineau
  • 6,036
  • 3
  • 34
  • 47
Efi Fogel
  • 730
  • 5
  • 11
  • The reason why I use `CGAL::Arr_conic_traits_2` instead of `CGAL::Arr_circle_segment_traits_2` is that the subdivision of the plane is based on an inset polygon which type is `CGAL::Gps_traits_2::Polygon_2`. Then changing the traits class used by the program is not a solution. – Flabetvibes Feb 27 '14 at 14:22
  • 1
    Well, why not use CGAL::Gps_traits_2::Polygon_2? The traits determines the number type. It is a purpose, a reason, and a goal... – Efi Fogel Mar 01 '14 at 08:10
  • The use of `Gps_traits_2::Polygon_2` needs a conversion from `Gps_traits_2::Polygon_2` (i.e. type result of an inset). That is possible, however my division of the two-dimensional space of real numbers is not a general polygon but a set of general polygons which might share some common edges. That is why the `Gps_traits_2::Polygon_2` is too high level, then I can use the underlying type `Arrangement_2` but this does not allow me to deal with circle with algebraic coordinate. – Flabetvibes Mar 01 '14 at 14:02
  • 1
    Let's go back one step for a second. Have you considered using CGAL::Gps_circle_segment_traits_2 to compute the inset? If this is an option, look at the example of ex_approx_offset.cpp in our book, namely, CGAL Arrangements and Their Applications. It's listed in Chapter 9, and the code can be obtained from our Web Page http://acg.cs.tau.ac.il/cgal-arrangement-book/source-code-data-and-miscellaneous-files – Efi Fogel Mar 02 '14 at 17:12
  • Yes I have considered to use the `approximated_inset_2` function (see [2D Minkowski Sums](http://doc.cgal.org/latest/Minkowski_sum_2/index.html#title7)). However, for some reasons, I need to get an inset with angles between two arcs less than 180° (in its interior). Unfortunately the approximation do not give me this property. – Flabetvibes Mar 03 '14 at 11:05
  • It would be great if the `exact_inset` function requires an instance of an arrangement-traits class that is capable of handling segments and circle in an exact manner. But what about circle with algebraic coordinate ? – Flabetvibes Mar 03 '14 at 11:11
1

As far as I know, and as I understand the section of the CGAL manual about it, there is no traits class to deal with circular arcs with algebraic coordinates.

(I will forward your question to CGAL developers to be sure. I will edit my answer once I know more.)

lrineau
  • 6,036
  • 3
  • 34
  • 47