Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Segment has_on() question

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Segment has_on() question


Chronological Thread 
  • From: "Vineet Chaoji" <>
  • To:
  • Subject: Re: [cgal-discuss] Segment has_on() question
  • Date: Sat, 9 Feb 2008 13:34:36 -0500
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=I0kph3xnk/ISjDEBn0iouj/u608WPRRd2HBOngTewjWvlThwQn3Mj61TvJGdQA1pv4JNbaw5ZKl9NmChCkLCiC+jbFCTlAdChBITouc9/R8OKW4GWId7EKoLVMt+xGSWRZfzsOkF7Z6+H1X/AHdDS6Xaome8s8y/5qTH+JcgvpY=

Thank you for such a quick response, Eric.

I went through the link regarding the CGAL philosophy. I think I will go with your second suggestion.

I have a followup question though. I looked through the CGAL examples, but could not figure out how to use the Filtered_predicates_exact_construction_kernel (actually I found other kernel types but not this one). I am not sure how I could use the Segment_d and Cartesian_d with this new kernel type. Could you please point me in the right direction?

Thank you once again.
Regards,
Vineet

On Feb 9, 2008 12:30 PM, Eric Berberich <> wrote:
wrote:
> Hi Everyone,
>
> I am quite a newbie to CGAL.
>
> I was trying to run a simple example, but I was not getting the expected output. I am trying to find if a point is on a line segment. My code is as follows
>
>   typedef CGAL::Cartesian_d<double> K;
>   typedef K::Segment_d CGAL_Segment;
>
>   double* arr = new double[2];
>   arr[0] = 2.0;
>   arr[1] = 4.0;
>   CGAL_Point p1(2, arr, arr+2);
>
>   arr[0] = 5.0;
>   arr[1] = 8.0;
>   CGAL_Point p2(2, arr, arr+2);
>   CGAL_Segment s(p1, p2);
>   cout << "Segment = " << s << endl;
>
>   vector<double> vec;
>   double len = std::sqrt(v.squared_length());
>   for(int i=0; i < v.dimension(); i++) {
>     vec.push_back(v[i]/len);
>   }
>   CGAL_Vector unit_vec(v.dimension(), vec.begin(), vec.end()); // Unit vector.
>
>   cout << "Is p5 on segment s = " << s.has_on(p1 + unit_vec) << endl;
>
> It is easy to see that the point p1+unit_vec ([2.6, 4.8] in this case) is on the segment. Why does has_on() say that the point is not on the segment?
>
> Thank you in anticipation.
> Regards,
> Vineet
>


Might be a problem, because your are using floating point numbers. Have
a look at CGAL's philosophy at http://www.cgal.org/philosophy.html and
decide thenm whether you want to switch to another number type. Or maybe
you want to switch to Filtered_predicates_exact_construction_kernel ..

 Best regards, eriC
--
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