Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Circle_2 and Segment_2 intersection

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Circle_2 and Segment_2 intersection


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Circle_2 and Segment_2 intersection
  • Date: Thu, 09 Jul 2015 08:00:34 +0200
  • Organization: GeometryFactory

What kernel are you using?

On 07/09/2015 01:06 AM, Dylan Lawrence wrote:
After a lot of wrestling I was able to get my code working, but I think
I'm missing something, below is my code and then the output

Line_2 l(Point_2(2, 4), Point_2(6, 8));
Circle_2 c(Point_2(3, 7),3);

std::vector<IntersectOut> output;

typedef CGAL::Dispatch_output_iterator <
CGAL::cpp11::tuple<IntersectOut>,
CGAL::cpp0x::tuple<std::back_insert_iterator<std::vector<IntersectOut>>>>
Dispatcher;

Dispatcher disp =
CGAL::dispatch_output<IntersectOut>(std::back_inserter(output));
CGAL::intersection(l, c, disp);

if (output.size() > 0)
{
std::cout << CGAL::to_double(output[0].first.x()) << ", " <<
CGAL::to_double(output[0].first.y()) << std::endl;
std::cout << output[0].second << std::endl;
if (output.size() > 1)
{
std::cout << CGAL::to_double(output[1].first.x()) << ", " <<
CGAL::to_double(output[1].first.y()) << std::endl;
}
}


*Output*

3.29289, 5.29289

1

4.70711, 6.70711


However on Wolfram using that circle and line it says the intersections
should occur at

((4-sqrt(7/2), 6-sqrt(7/2)) | (4+sqrt(7/2),
6+sqrt(7/2)))~~((2.12917, 4.12917) | (5.87083, 7.87083))


This seems to be giving a different answer. I checked a few other cases
and some align with Wolfram but others are off like this and they seem
to be off by more than a floating point error.

On Tue, Jul 7, 2015 at 2:04 AM, Sebastien Loriot (GeometryFactory)
<

<mailto:>>
wrote:

The type is boost::optional< boost::variant<T..> > where the types
in the variant depends on what you call intersection with.
In you case, it can only be
std::pair<Circular_arc_point_2<CircularKernel>, unsigned>


http://doc.cgal.org/latest/Kernel_23/group__intersection__circular__grp.html


Have a look at the example on this page how to get the type out of
the boost one:
http://doc.cgal.org/latest/Kernel_23/group__intersection__linear__grp.html

Sebastien.

On 07/07/2015 08:56 AM, Dylan Lawrence wrote:

After quite a bit of rewrites I was able to actually get the
intersections running using CGAL::intersection() I know my vector
contains the intersections however what exactly is in that
vector. It
seems to be an extension of a boost type but it's unclear what
it is.
Essentially I have my intersections, but I do not understand how to
access them to get the point of incidence for an intersection.

On Tue, Jun 23, 2015 at 12:55 PM, Laurent Rineau
(CGAL/GeometryFactory)

<

<mailto:>

<mailto:

<mailto:>>>
wrote:

Le Tuesday 23 June 2015 16:22:27 Monique Teillaud a écrit :
> a Line_arc_2 can be constructed from a Segment_2


>http://doc.cgal.org/latest/Circular_kernel_2/classCGAL_1_1Line__arc__2.html
>
> then you can intersect it with a circle or a circular arc


>http://doc.cgal.org/latest/Circular_kernel_2/classCircularKernel_1_1DoInters
> ect__2.html
> Le 23/06/15 04:22, dlawre14 a écrit :
> > I've done some searching of the docs but cannot find
any entry of a
> > Circle_2 and Segment_2 intersecting. Can such a thing
be done or do I
> > need to convert the Segment_2 to another type?

See also :

- the Intersect_2 functor:


http://doc.cgal.org/latest/Circular_kernel_2/classCircularKernel_1_1Intersect__2.html

- the corresponding 'do_intersect' and 'intersection' global
functions
overloads:


http://doc.cgal.org/latest/Kernel_23/group__do__intersect__circular__grp.html

http://doc.cgal.org/latest/Kernel_23/group__intersection__circular__grp.html

--
Laurent Rineau, PhD
R&D Engineer at GeometryFactory http://www.geometryfactory.com/
Release Manager of the CGAL Project http://www.cgal.org/


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





--
Dylan Lawrence
Masters Student
Bioinformatics and Computational Biology



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





--
Dylan Lawrence
Masters Student
Bioinformatics and Computational Biology




Archive powered by MHonArc 2.6.18.

Top of Page