Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] precondition violation when intersecting a line with a sphere

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] precondition violation when intersecting a line with a sphere


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] precondition violation when intersecting a line with a sphere
  • Date: Fri, 13 May 2011 07:10:52 +0200

See:

http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Kernel_23_ref/Function_intersection.html#Index_anchor_446

and in particular the part:
"With the 3D Spherical Kernel (see Chapter 14) "

The object should be:
std::pair<Circular_arc_point_3<SphericalKernel>, unsigned>, where the unsigned integer is the multiplicity of the corresponding intersection point between obj1 and obj2,


yanyajie wrote:
Dear S.
I fixed the problem by sustituting int with double in the algebraic_kernel, but intersection routine just doesn’t return objects whose type is what I expect. In the following code, the intersection definitely happens, and two objects are inserted in vector isecs. If nothing goes wrong, they should be two Point_3_SK instances, right? However, object_cast<Point_3_SK> only yields null pointer.
-------------------------------------------------------------------------------------
typedef SphericalK::Line_3 Line_3_SK;
typedef SphericalK::Sphere_3 Sphere_3_SK;
Line_3_SK line (Point_3_SK(0, 0, 0), Point_3_SK(0, 0, 1));
Sphere_3_SK sphere(Point_3_SK(0, 0, 0), 5);
vector<CGAL::Object> isecs;
CGAL::intersection(line, sphere, std::back_inserter(isecs));
const Point_3_SK *isec_p = CGAL::object_cast<Point_3_SK>(&isecs[0]);
-------------------------------------------------------------------------------------
Where does the problem lie?
Thank you for your time!
Yan.
*From:* yanyajie <mailto:>
*Sent:* Friday, May 13, 2011 10:32 AM
*To:* <mailto:>
*Subject:* Re: [cgal-discuss] precondition violation when intersecting a line with a sphere
Dear S.
O! I was so naïve, as I thought “int” should be the type used to instantiate Algebraic_kernel when I saw a RT in


CGAL::Algebraic_kernel_for_spheres_2_3<RT>

OK, thank you! I’ll see if this correction could solve the problem.
Yan.
-----原始邮件-----
From: Sebastien Loriot (GeometryFactory)
Sent: Friday, May 13, 2011 1:45 AM
To:

Subject: Re: [cgal-discuss] precondition violation when intersecting a line with a sphere
Algebraic_kernel_for_spheres_2_3<int>
should be Algebraic_kernel_for_spheres_2_3<double>
You also should consider using an exact type.
Please read:
http://www.cgal.org/FAQ.html#inexact_NT
yanyajie wrote:
> Hi,
> > I encounterd a precondition violation error when I was trying to find
> the intersection between a line and a sphere.
> -----------------------------------------------------------------------------------
> CGAL error: precondition violation!
> Expression : !p.degenerated()
> File :
> d:\codes\lib\cgal-3.7\include\cgal\algebraic_kernel_for_spheres\int
> ernal_functions_on_roots_and_polynomial_1_3_and_2_3.h
> Line : 212
> Explanation:
> Refer to the bug-reporting instructions at
> http://www.cgal.org/bug_report.html
> -------------------------------------------------------------------------------------
> > I provide necessary info in the following to help reproduce the error:
> > ------------------------------------------------------------------------------------------------------------------------------------------------------
> typedef CGAL::Cartesian<double> K;
> typedef CGAL::Spherical_kernel_3<K,
> CGAL::Algebraic_kernel_for_spheres_2_3<int> > SphericalK;
> typedef SphericalK::Point_3 Point_3_SK;
> > // to compute the intersection, I construct a line and a sphere using
> the spherical kernel as follows:
> CGAL::Line_3<SphericalK> line(Point_3_SK(-0.1,-0.1,-0.1),
> Point_3_SK(-0.1,-0.1,0.0));
> CGAL::Sphere_3<SphericalK> s(Point_3_SK(0, 0, 0), 0.1); // c is a Point_3
> vector<CGAL::Object> isecs;
> CGAL::intersection(line, s, std::back_inserter(isecs));
> ------------------------------------------------------------------------------------------------------------------------------------------------------
> > The assertion error is issued from within CGAL::intersection, when it
> tries to do the confirmation,
> actually, from this function:
> > template < class AK, class OutputIterator >
> inline
> OutputIterator
> solve(const typename AK::Polynomials_for_line_3 &p,
> const typename AK::Polynomial_for_spheres_2_3& s,
> OutputIterator res )
> {
> ...
> // we must have a line
> CGAL_kernel_precondition(!p.degenerated());
> ...
> }
> > > Does this failure of assertion indicates I constructed a degenerate
> line? But from the code you can see the line should be non-degenerate.
> > Thanks if anyone can point out the problem!
> > > Yan.
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss




Archive powered by MHonArc 2.6.16.

Top of Page