Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] About .locate function

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] About .locate function


Chronological Thread 
  • From: ffmm3 <>
  • To:
  • Subject: Re: [cgal-discuss] About .locate function
  • Date: Tue, 22 Oct 2013 01:13:56 -0700 (PDT)

If I want determine the relative position between the point(0.7,0.3) and the
triangle with vertices(-1,0)(1,0)(0,1) precisely, what should I do?


Sebastien Loriot (GeometryFactory) wrote
> Rational coordinates cannot be represented exactly using a floating
> point representation.
>
> Try to compile this:
>
> #include
> <iostream>
> #include
> <iomanip>
> int main()
> {
> std::cout << std::setprecision(18) << 0.7 << std::endl;
> }
>
> Sebastien.
>
> On 10/22/2013 03:14 AM, ffmm3 wrote:
>> Hello, I am a newer to CGAL, and when I use the .locate() function to
>> locate
>> a point in a triangle, there is some problem.
>> First I build a triangle with three point (-1,0) (1,0) (0,1),
>> Then I check some points' relative location with the triangle,
>> the points are:
>> p0(0.8, 0.1) ---- locate in the triangle
>> p1(0.95, 0) ---- locate on the edge (-1,0) ---- (1,0)
>> p2(0.8, 0.2) ---- locate on the edge (1,0) ---- (0,1)
>> p3(0.6, 0.4) ---- locate on the edge (1,0) ---- (0,1)
>> p4(0.7,0.3) ---- locate on the edge (1,0) ---- (0,1)
>> But the locate results are:
>> p0 ---- FACE, right!
>> p1 ---- EDGE, right!
>> p2 ---- OUTSIDE_CONVEX_HULL, wrong!
>> p3 ---- EDGE, right!
>> p4 ---- FACE, wrong!
>> while the points p2, p3, p4 are locating on the same edge (1,0) ----
>> (0,1)
>>
>> What's the problem?
>>
>> The code:
>>
>> typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
>> typedef CGAL::Delaunay_triangulation_2
> <K>
> Delaunay_triangulation;
>> void main()
>> {
>> //generate the triangles
>> std::vector
> <Point2>
> pts;
>> pts.push_back(Point2(1,0));
>> pts.push_back(Point2(-1,0));
>> pts.push_back(Point2(0,1));
>> Delaunay_triangulation dt;
>> dt.insert(pts.begin(), pts.end());
>>
>> //locate point in the triangle
>> Point2 pt0 = Point2(0.8, 0.1);//the point located in the triangle.(on the
>> FACE ?)
>> Point2 pt1 = Point2(0.95, 0);//the point located on the segment ( (1,0)
>> ----
>> (-1,0) ) (on the EDGE ?)
>> Point2 pt2 = Point2(0.8, 0.2);//the point locate on the segment ( (1,0)
>> ----
>> (0,1) ) (on the EDGE ?)
>> Point2 pt3 = Point2(0.6, 0.4);//the point locate on the segment ( (1,0)
>> ----
>> (0,1) ) (on the EDGE ?)
>> Point2 pt4 = Point2(0.7,0.3);//the point locate on the segment ( (1,0)
>> ----
>> (0,1) ) (on the EDGE ?)
>> Face_handle fh0, fh1, fh2, fh3, fh4;
>> Delaunay_triangulation::Locate_type lt0, lt1, lt2, lt3, lt4;
>> int li;
>> fh0 = dt.locate(pt0, lt0, li);//for pt0, lt0 is equal to FACE, right!
>> fh1 = dt.locate(pt1, lt1, li);//for pt1, lt1 is equal to EDGE, right!
>> fh2 = dt.locate(pt2, lt2, li);//for pt2, lt2 is equal to
>> OUTSIDE_CONVEX_HULL, I think it's wrong!
>> fh3 = dt.locate(pt3, lt3, li);//for pt3, lt3 is equal to EDGE, right!
>> fh4 = dt.locate(pt4, lt4, li);//for pt4, lt3 is equal to FACE, I thing
>> it's
>> wrong!
>> }
>>
>>
>>
>> --
>> View this message in context:
>> http://cgal-discuss.949826.n4.nabble.com/About-locate-function-tp4658262.html
>> Sent from the cgal-discuss mailing list archive at Nabble.com.
>>
>
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://sympa.inria.fr/sympa/info/cgal-discuss





--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/About-locate-function-tp4658262p4658269.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.18.

Top of Page