Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Sphere-Line Intersection

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Sphere-Line Intersection


Chronological Thread 
  • From: Eric Berberich <>
  • To:
  • Subject: Re: [cgal-discuss] Sphere-Line Intersection
  • Date: Fri, 04 Jul 2008 09:05:25 +0200

Thomas Zangl - Home wrote:
Am Thu, 3 Jul 2008 22:57:58 +0200, schrieb "Pedro_Machado_Manhães_de_Castro" <>:

Hi!

typedef typename Kernel::FT FT;
typedef typename Root_of_traits< FT >::RootOf_2 Root_of_2;

const Root_of_2 mu = make_root_of_2(-b/(2*a), FT(1), (b*b - 4*a*c)/(4*a*a));
const Root_of_2 x = x1 + mu*(x2-x1);
const Root_of_2 y = y1 + mu*(y2-y1);
const Root_of_2 z = z1 + mu*(z2-z1);

Note: You can&#39;t store them as coordinates for points.
You may want to have a look at CORE::Expr (slow) if you need absolutely to work with CGAL points. Otherwise, you have to find another way to store them. Just remember that whenever using FT&#39;s like Gmpq or MP_Float, you are using something that do not support Root_of_2 (rationals do not include them), and the correspondent Points will not support as well.

I already suspected something like this. At least, any ideas how I can
improve accuracy of my intersection code?

The result should be a Point_3 based on Gmpq.

TIA,

gmpq is not able to exactly represent the square-root that naturally exists (except for degenerate cases, where the root is a rational) for the coordinates of the intersection points of a sphere and a line. Either you compute an interval of two gmpq that contain the exact coordinates, or you switch to CORE::Expr (or leda::real) or you use the Root_of number types. I currently don't see another option.

It is the mathematics that result in this "gmpq-is-not-sufficient" case. Believe us, it would be much nicer, if curved geometry would stay in rational numbers ;-)

eriC



Archive powered by MHonArc 2.6.16.

Top of Page