Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Re: conversion between Gmpq and double

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Re: conversion between Gmpq and double


Chronological Thread 
  • From: Jean Pierre Charalambos <>
  • To:
  • Subject: Re: [cgal-discuss] Re: conversion between Gmpq and double
  • Date: Fri, 20 Feb 2009 19:13:26 -0500
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=J5tA72ikBq3RT52SokvBTInDhwId/KrTVZxOlHj/Ru4S+GYSbXayRazGWGdZJtlboM YLyXLe18hOMBrebcCa6UKsUj9gkUbWCwjBtdJbjCwouOOU6Y/JMEW9Dw1NHj2KJQ4kyj KGQ15ZESQhY5qwU2TxJQ1HuDY5duoyuqaurnE=

Hi,

Thx Sebastien, I was able to fix it! I want to show how:

1. I added QMAKE_CXXFLAGS += -frounding-math to my qmake pro.
2. It worked when defining: typedef float FT (as in my code original version).
3. For typedef CGAL::Gmpq FT;
//radius:
double a, b, t;
t = CGAL::to_double(ms.discriminant());
a = CGAL::to_double(ms.radius().first);
b = CGAL::to_double(ms.radius().second);
radius = ((a + ( b*sqrt(t)));
//center:
for (c_it=ms.center_cartesian_begin();
c_it!=ms.center_cartesian_end(); ++c_it) {
a = CGAL::to_double((*c_it).first);
b = CGAL::to_double((*c_it).second);
center[i] = (float) (a + ( b*sqrt(t)));
i++;
}

Cheers!

--
Jean Pierre



On Fri, Feb 20, 2009 at 8:31 AM, Sebastien Loriot
<>
wrote:
> Sebastien Loriot wrote:
>
> Jean Pierre Charalambos wrote:
>
> Hi!
>
> any thought regarding my conversion issue? I have been not able to fix it :(
>
> Best,
>
> Jean Pierre
>
>
>
> On Tue, Feb 17, 2009 at 6:59 PM, Jean Pierre Charalambos
> <>
> wrote:
>
>
> Hi cgal users,
>
> I'm new to cgal 3.4 and I want to compute the minimal bounding sphere of a
> set
> of spheres. So I just tried to adapt the min_sphere_of_spheres_d_3.cpp
> example, but I have a problem when trying to convert the sphere types
> (radius
> and center) to double types. I suppose this is a basic question, but I have
> read the faqs and I googled a lot without success. My code is:
>
> typedef CGAL::Gmpq FT;
> typedef CGAL::Cartesian<FT> K;
> typedef CGAL::Min_sphere_of_spheres_d_traits_3<K,FT> Traits;
> typedef CGAL::Min_sphere_of_spheres_d<Traits> Min_sphere;
> typedef K::Point_3 Point;
> typedef Traits::Sphere Sphere;
>
> //after checking in the spheres in ms and computing the minimal sphere (just
> like in the example) I attempted the conversion as follows:
>
> radius = CGAL::to_double(ms.radius());
>
> However, I got the following compilation error:
>
> cannot convert 'CGAL::Null_tag' to 'double' in assignment
>
> If I use "typedef double FT" (instead of typedef CGAL::Gmpq FT) and retrieve
> the radius with "radius = ms.radius()" the code compiles (and it actually
> runs
> perfectly in cgal3.3), but I get the following errror at running time:
>
> terminate called after throwing an instance of 'CGAL::Assertion_exception'
> what(): CGAL ERROR: assertion violation!
> Expr: -CGAL_IA_MUL(-1.1, 10.1) != CGAL_IA_MUL(1.1, 10.1)
> File: /usr/include/CGAL/Interval_nt.h
> Line: 154
> Explanation: Wrong rounding: did you forget the -frounding-math option if
> you
> use GCC?
> Aborted
>
> Thank you in advanced for your suggestions,
>
> Jean Pierre
> --
> You don't become a failure until you're satisfied with being one.
>
>
>
>
> Hello,
>
> According to
> http://www.cgal.org/Manual/3.4/doc_html/cgal_manual/Bounding_volumes_ref/Class_Min_sphere_of_spheres_d.html
> and in particular the text after Min_sphere_of_spheres_d<Traits>::Result,
> the Result of radius() should in your case be a pair<FT,FT> (a,b)
> representing a number a+b*sqrt(t), where t is given by member function
> disciminant().
>
>
> Sebastien
>
>
>
> Sorry my answer was half complete.
> Then, one solution of your problem is to apply the to_double to a,b and t.
>
> Sebastien.
>
>
>
>
>



Archive powered by MHonArc 2.6.16.

Top of Page