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

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

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

stu002
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<Exact_circular_kernel_2> and
Circular_arc_point_2<Exact_circular_kernel_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


Reply | Threaded
Open this post in threaded view
|

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

Efi Fogel
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<Exact_circular_kernel_2> and
Circular_arc_point_2<Exact_circular_kernel_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



Reply | Threaded
Open this post in threaded view
|

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

stu002
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 <CGAL/MP_Float.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_circle_segment_traits_2.h>

// We need an exact, rational number type for coordinates
using Coordinate = CGAL::Quotient<CGAL::MP_Float>;

// Linear 2D kernel with cartesian points
using Linear_Kernel   = CGAL::Cartesian<Coordinate>;
using Linear_Circle_2 = Linear_Kernel::Circle_2;

// Bring in the 2D arrangement traits
using Circle_Traits_2 = CGAL::Arr_circle_segment_traits_2<Linear_Kernel>;

// 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


Reply | Threaded
Open this post in threaded view
|

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

Efi Fogel
1. I guess it does, but why not using one of the predefined kernel (see below)?

#include <CGAL/Exact_predicates_exact_constructions_kernel.h>

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 <[hidden email]> 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 <CGAL/MP_Float.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_circle_segment_traits_2.h>

// We need an exact, rational number type for coordinates
using Coordinate = CGAL::Quotient<CGAL::MP_Float>;

// Linear 2D kernel with cartesian points
using Linear_Kernel   = CGAL::Cartesian<Coordinate>;
using Linear_Circle_2 = Linear_Kernel::Circle_2;

// Bring in the 2D arrangement traits
using Circle_Traits_2 = CGAL::Arr_circle_segment_traits_2<Linear_Kernel>;

// 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



Reply | Threaded
Open this post in threaded view
|

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

stu002
On Sun, Feb 18, 2018 at 1:46 AM, Efi Fogel <[hidden email]> wrote:

> 1. I guess it does, but why not using one of the predefined kernel (see
> below)?
>
> #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
>
> 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.)

Thanks for the pointers Efi -- much appreciated.

Does that approach of using a predefined kernel also hold for conic curves?

Following the example in
https://doc.cgal.org/latest/Arrangement_on_surface_2/Arrangement_on_surface_2_2conics_8cpp-example.html,
the example uses explicit choices of number type etc.

I'm asking so I can create ellipses and elliptic arcs using CGAL.
(Even if I have to create the bounding box and affine transformation
methods myself).

Thanks,

Stu

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

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

Efi Fogel
1. The  CGAL::Exact_predicates_exact_constructions_kernel is defined as Lazy_kernel<Simple_cartesian<Epeck_ft> > (see Exact_predicates_exact_constructions_kernel.h).
You can try to replace both occurrences of CGAL::Cartesian<SOMETHING> with Lazy_kernel<Simple_cartesian<SMETHING> >, but I haven't tried it with this particular traits.

2. Usually, a traits that supports a limited type of curves would be more efficient then a traits that supports a broader type.
For example, the Arr_segment_traits_2 is more efficient then the Arr_algebraic_segment_traits_2 for handling segments.
However, the Arr_conic_traits_2.h is a bit old and the Arr_algebraic_segment_traits_2 might beat it for handling conics in certain cases.

   ____  _        ____             _
  /_____/_) o    /__________  __  //
 (____ (   (    (    (_/ (_/-(-'_(/
                         _/



On 17 February 2018 at 21:01, Stuart Hungerford <[hidden email]> wrote:
On Sun, Feb 18, 2018 at 1:46 AM, Efi Fogel <[hidden email]> wrote:

> 1. I guess it does, but why not using one of the predefined kernel (see
> below)?
>
> #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
>
> 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.)

Thanks for the pointers Efi -- much appreciated.

Does that approach of using a predefined kernel also hold for conic curves?

Following the example in
https://doc.cgal.org/latest/Arrangement_on_surface_2/Arrangement_on_surface_2_2conics_8cpp-example.html,
the example uses explicit choices of number type etc.

I'm asking so I can create ellipses and elliptic arcs using CGAL.
(Even if I have to create the bounding box and affine transformation
methods myself).

Thanks,

Stu

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss