Intersection of segments

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Intersection of segments

Amit Pendharkar
Hi All,

I want to find if the given two segments or a segment and a point intersect or not.

I am trying to use SegmentDelaunayGraphTraits_2::Arrangement_type (that takes values DISJOINT, IDENTICAL, CROSSING etc) and the function arrangement_type(), but it gives me error saying that its protected.

How do I define Arrangement_type & make use of arrangement_type() to find the intersection point if any?

I don't really want to make use of the sweep line algorithm as explained in Chapter21: 2D Intersection of Curves of cgal manual.

All i/ps are highly appreciated.

Thanks & Regards,
Amit Pendharkar
Reply | Threaded
Open this post in threaded view
|

Re: Intersection of segments

Julien Demouth
Hi Amit,

I'm not sure to understand the question but if you want to know whether
two 2D segments intersect you can use CGAL::do_intersect (it is included
with kernels). If you want to know if a point is on a segment, you can
use has_on member function from the class CGAL::Segment_2.

CGAL::Exact_predicates_inexact_constructions_kernel K;

// Define four points a1, b1, a2, b2.

CGAL::Segment_2<K> s1 (a1, b1);
CGAL::Segment_2<K> s2 (a2, b2);

if (CGAL::do_intersect (s1, s2))
     std::cout << "They intersect\n";
else
     std::cout << "They don't\n";

if (s1.has_on (CGAL::Point_2<K> (1, 0, 0)))
     std::cout << "s1 contains (1, 0, 0)\n"

I hope it answers your questions.

Best,
Julien

Amit Pendharkar a écrit :

> Hi All,
>
> I want to find if the given two segments or a segment and a point
> intersect or not.
>
> I am trying to use /SegmentDelaunayGraphTraits_2::Arrangement_type
> /(that takes values /DISJOINT/, /IDENTICAL/, /CROSSING etc/) and the
> function /arrangement_type(),/ but it gives me error saying that its
> protected.
>
> How do I define Arrangement_type & make use of arrangement_type() to
> find the intersection point if any?
>
> I don't really want to make use of the sweep line algorithm as explained
> in Chapter21: 2D Intersection of Curves of cgal manual.
>
> All i/ps are highly appreciated.
>
> Thanks & Regards,
> Amit Pendharkar

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss