# Convert points and circles from 2D linear kernel to 2D circular kernel?

6 messages
Open this post in threaded view
|

## Convert points and circles from 2D linear kernel to 2D circular kernel?

 Hi, I have a bunch of CGAL 2D points and 2D circles that are parameterized by a 2D linear geometry kernel (in this case CGAL::Exact_predicates_exact_constructions_kernel). I'd like to create 2D circular arcs using these linear points and circles as construction parameters. I can see the relevant circular arcs are not in the linear 2D geometry kernel but the 2D circular geometry kernel. (Although there is a Circle_2 in the linear kernel but no arcs). So I need to create instances of Circular_arc_2 parameterized by (say) CGAL::Exact_circular_kernel_2. For that I need instances of Circle_2 and Circular_arc_point_2. Is there a straightforward way or indeed, any way, to convert the linear kernel circles and points I have between these two kernels? Thanks in advance, Stu -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss
Open this post in threaded view
|

## Re: Convert points and circles from 2D linear kernel to 2D circular kernel?

 You can use the Arr_circle_segment_traits_2 geometry traits module of the 2D Arrangement package. This traits uses the exact same number type that the circular kernel uses to represent circular arcs. It is called CGAL: :SQRT_EXTENSION.On Feb 13, 2018 6:59 AM, "Stuart Hungerford" <[hidden email]> wrote:Hi, I have a bunch of CGAL 2D points and 2D circles that are parameterized by a 2D linear geometry kernel (in this case CGAL::Exact_predicates_exact_constructions_kernel). I'd like to create 2D circular arcs using these linear points and circles as construction parameters. I can see the relevant circular arcs are not in the linear 2D geometry kernel but the 2D circular geometry kernel. (Although there is a Circle_2 in the linear kernel but no arcs). So I need to create instances of Circular_arc_2 parameterized by (say) CGAL::Exact_circular_kernel_2. For that I need instances of Circle_2 and Circular_arc_point_2. Is there a straightforward way or indeed, any way, to convert the linear kernel circles and points I have between these two kernels? Thanks in advance, Stu -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss
Open this post in threaded view
|

## Re: Convert points and circles from 2D linear kernel to 2D circular kernel?

 On Tue, Feb 13, 2018 at 5:26 PM, Efi Fogel <[hidden email]> wrote: > You can use the Arr_circle_segment_traits_2 geometry traits module of the 2D > Arrangement package. This traits uses the exact same number type that the > circular kernel uses to represent circular arcs. It is called CGAL: > :SQRT_EXTENSION. Thanks for the pointer Efi.  Does the following example implement the approach you're suggesting? #include #include #include #include // We need an exact, rational number type for coordinates using Coordinate = CGAL::Quotient; // Linear 2D kernel with cartesian points using Linear_Kernel   = CGAL::Cartesian; using Linear_Circle_2 = Linear_Kernel::Circle_2; // Bring in the 2D arrangement traits using Circle_Traits_2 = CGAL::Arr_circle_segment_traits_2; // We need the circular entities from the 2D trait using Circle_Point_2 = Circle_Traits_2::Point_2; using Circle_Curve_2 = Circle_Traits_2::Curve_2; // Setup the reference circle for the arc auto circle_center = Linear_Kernel::Point_2(0.0, 0.0); auto base_circle   = Linear_Circle_2(circle_center, 100.0); // Setup the arc start and end points auto start_pt = Circle_Point_2(10.0, 0.0); auto end_pt   = Circle_Point_2(0.0, 10.0); // Create the arc auto my_arc = Circle_Curve_2(base_circle, start_pt, end_pt); Can I also check whether it's possible to apply an orthogonal transform to a circular arc?  Or find the bounding box (AABB) of one? I get the impression that circular arcs in CGAL are not intended to be widely useful like other geometric entities (e.g. polygons, line segments), in that case it might be easier to define my own arc type? Thanks again, Stu -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss
Open this post in threaded view
|

## Re: Convert points and circles from 2D linear kernel to 2D circular kernel?

 1. I guess it does, but why not using one of the predefined kernel (see below)?#include typedef CGAL::Exact_predicates_exact_constructions_kernel   Linear_kernel;2. The points and curve types defined by the circular kernel and the points and curves defined by the Arr_circle_segment_traits_2 traits are the same. They use coordinates represented by a type called CGAL: :Sqrt_extension. You can read more about it in the manual.)Operations performed on geometric objects defined using this type are efficient. (The alternative, for example, would be using an algebraic number type, which is much less efficient).Naturally all operations required by the traits concept are implemented (using this type).However, operations on this type, or geometric object defined using this type, are indeed limited.   ____  _        ____             _  /_____/_) o    /__________  __  // (____ (   (    (    (_/ (_/-(-'_(/                         _/ On 13 February 2018 at 23:02, Stuart Hungerford wrote:On Tue, Feb 13, 2018 at 5:26 PM, Efi Fogel <[hidden email]> wrote: > You can use the Arr_circle_segment_traits_2 geometry traits module of the 2D > Arrangement package. This traits uses the exact same number type that the > circular kernel uses to represent circular arcs. It is called CGAL: > :SQRT_EXTENSION. Thanks for the pointer Efi.  Does the following example implement the approach you're suggesting? #include #include #include #include // We need an exact, rational number type for coordinates using Coordinate = CGAL::Quotient; // Linear 2D kernel with cartesian points using Linear_Kernel   = CGAL::Cartesian; using Linear_Circle_2 = Linear_Kernel::Circle_2; // Bring in the 2D arrangement traits using Circle_Traits_2 = CGAL::Arr_circle_segment_traits_2; // We need the circular entities from the 2D trait using Circle_Point_2 = Circle_Traits_2::Point_2; using Circle_Curve_2 = Circle_Traits_2::Curve_2; // Setup the reference circle for the arc auto circle_center = Linear_Kernel::Point_2(0.0, 0.0); auto base_circle   = Linear_Circle_2(circle_center, 100.0); // Setup the arc start and end points auto start_pt = Circle_Point_2(10.0, 0.0); auto end_pt   = Circle_Point_2(0.0, 10.0); // Create the arc auto my_arc = Circle_Curve_2(base_circle, start_pt, end_pt); Can I also check whether it's possible to apply an orthogonal transform to a circular arc?  Or find the bounding box (AABB) of one? I get the impression that circular arcs in CGAL are not intended to be widely useful like other geometric entities (e.g. polygons, line segments), in that case it might be easier to define my own arc type? Thanks again, Stu -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss