Subject: CGAL users discussion list
List archive
- From: Myirci <>
- To:
- Subject: Re: [cgal-discuss] Type conversion: Ring Type to Rational
- Date: Thu, 14 Feb 2013 22:56:45 +0100
Thank you sebastien,
it solved my conversion problem !
On Thu, Feb 14, 2013 at 4:55 PM, Sebastien Loriot (GeometryFactory) <> wrote:
You can try that:Rational rr( CGAL::exact(r).mpq() );
Gt::RT r = 0.75;
Sebastien--
On 02/14/2013 11:50 AM, Myirci wrote:
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
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
Murat Yirci
- [cgal-discuss] Type conversion: Ring Type to Rational, Myirci, 02/14/2013
- Re: [cgal-discuss] Type conversion: Ring Type to Rational, Sebastien Loriot (GeometryFactory), 02/14/2013
- Re: [cgal-discuss] Type conversion: Ring Type to Rational, Myirci, 02/14/2013
- Re: [cgal-discuss] Type conversion: Ring Type to Rational, Sebastien Loriot (GeometryFactory), 02/14/2013
Archive powered by MHonArc 2.6.18.