Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Type conversion: Ring Type to Rational

Subject: CGAL users discussion list

List archive

[cgal-discuss] Type conversion: Ring Type to Rational


Chronological Thread 
  • From: Myirci <>
  • To:
  • Subject: [cgal-discuss] Type conversion: Ring Type to Rational
  • Date: Thu, 14 Feb 2013 11:50:36 +0100

Bonjour,

I'm using segment delaunay graphs and conics arrangements. At some point of my program I need to convert Ring Type variables to Rational variables to create the conic arcs. My original code is very long, but I generated the same condition in the program below. How can I do the conversion? For just one simple parabola I can supply the Rational coefficients by hand but in my original program, the numbers are not so simple and the coefficients are calculated in run time.

Bonne journée
Merci beaucoup 

#include <iostream>

#include <CGAL/Exact_predicates_exact_constructions_kernel.h>


#include <CGAL/Segment_Delaunay_graph_2.h>


#include <CGAL/Segment_Delaunay_graph_traits_2.h>




typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Segment_Delaunay_graph_traits_without_intersections_2<


        Kernel,

CGAL::Integral_domain_without_division_tag> Gt;
typedef Gt::Point_2                                                                                             Point_2;


typedef CGAL::Segment_Delaunay_graph_2<Gt>                                             SDG_2;




#include <CGAL/basic.h>

#include <CGAL/Cartesian.h>

#include <CGAL/CORE_algebraic_number_traits.h>
#include <CGAL/Arrangement_2.h>


#include <CGAL/Arr_conic_traits_2.h>




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>               Traits_2;


typedef Traits_2::Curve_2                                                                                  Conic_arc_2;


typedef CGAL::Arrangement_2<Traits_2>                                                          Arrangement_2;




int main(void) {
    // Parabola: y = -3/4x²


    Gt::RT r = 0.75;


    Gt::RT s = 0;


    Gt::RT t = 0;


    Gt::RT u = 0;


    Gt::RT v = 1;


    Gt::RT w = 0;


    Point_2 ps = Point_2(2, -3);


    Point_2 pt = Point_2(-1, 0.75);




// Does not compile: RT number type must be converted to Rational! How?
    Conic_arc_2 arc(r,s,t,u,v,w, CGAL::COUNTERCLOCKWISE, ps, pt);


    if(!arc.is_valid()) { std::cout << "NOT VALID" << std::endl; }


    return 0;


}
--
Murat Yirci




Archive powered by MHonArc 2.6.18.

Top of Page