Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Create a correct arrangement with lines processed with linear_least_squares_fitting_2 function

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Create a correct arrangement with lines processed with linear_least_squares_fitting_2 function


Chronological Thread 
  • From: DamienDous <>
  • To:
  • Subject: Re: [cgal-discuss] Create a correct arrangement with lines processed with linear_least_squares_fitting_2 function
  • Date: Thu, 3 Dec 2015 03:22:06 -0800 (PST)
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=SoftFail ; spf=None
  • Ironport-phdr: 9a23:z1AN0RG5CSUAS3c8Bqolx51GYnF86YWxBRYc798ds5kLTJ74o8+wAkXT6L1XgUPTWs2DsrQf27SQ6/yrAzNIyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/niabqp9aJPE1hv3mUX/BbFF2OtwLft80b08NJC50a7V/3mEZOYPlc3mhyJFiezF7W78a0+4N/oWwL46pyv50IbKPhYq5tTaBEFC90dCcu9cjzvF/CSxGO7z0SSCINgx9QCk/E6h/9GZz+uy+/uutm0zSBJp7LS6spU2Gi87tzU02vzzwWMiYwtmDRkM15yqxB5wmwogR2hI/SbobSP/V3eubRfMgRWHFaDfpWAidOC4f5Y4oUBPcaJs5ZqZP8rh0At0iQHw6pUc/mzz5FgFPxwLZyh+goFADL2kosN8kIuWzXrdOzOr1EArP997XB0TiWN6Ae4jz68oWdKh0=

Hi Efi,

Thank you for your answer!

I tried the example using
Exact_predicates_exact_constructions_kernel_with_sqrt and I have a
compilation error. It seems that the function linear_least_squares_fitting_2
doesn't take this Kernel. Am I using it in the good way?

I also tried to convert the lines from Epick to Epeck using the mechanism
provided in the Algebraic Foundation package but as new user in CGAL I'm
kind of lost. I tried to use fraction decomposition in order to decompose
lines coefficients with Epick kernel and then recompose the coefficients
with Epeck Kernel but that didn't work. Is that the good way to convert the
lines from one Kernel to another?

Damien



Efi Fogel wrote
> Hi Damien,
>
> Use the Exact_predicates_exact_constructions_kernel_with_sqrt kernel or,
> when exactness can be compromised in favor of using a kernel that is more
> efficient for constructing the arrangement, convert the lines from one
> representation to the other using the mechanism provided in the Algebraic
> Foundation package.
>
> Please paste pretty code. (Not only not nicely indented, but also it seems
> that the '<' and '>' tags go converted by Nabble to &lt; and &gt; and, in
> addition, the ssl header inclusion is missing.)
>
> Efi
>
> ____ _ ____ _
> /_____/_) o /__________ __ //
> (____ ( ( ( (_/ (_/-(-'_(/
> _/
>
>
>
> On Tue, Dec 1, 2015 at 7:58 PM, DamienDous &lt;

> damien.d@

> &gt; wrote:
>
>> Hi,
>>
>> I need to create an arrangement with lines fitted by
>> linear_least_squares_fitting_2 function.
>>
>> I have a problem when I fit lines on points by using
>> linear_least_squares_fitting_2 function and after put the obtained lines
>> in
>> an arrangement using an Exact_predicates_exact_constructions_kernel. The
>> face number processed is incorrect.
>>
>> The following example fit three lines intersecting at the same point
>> using
>> Line_2 with Exact_predicates_inexact_constructions_kernel (the
>> linear_least_squares_fitting_2 can't take line with
>> Exact_predicates_exact_constructions_kernel because the function
>> processes
>> square root). To put the obtained lines in an arrangement using
>> Exact_predicates_exact_constructions_kernel , I convert the lines in
>> Segment_2 with Exact_predicates_exact_constructions_kernel and I
>> understand
>> that the problem come from this transformation but I don't know how to
>> use
>> linear_least_squares_fitting_2 function and then put the result in an
>> arrangement using Exact_predicates_exact_constructions_kernel.
>>
>> Also, I tried to use an arrangement with
>> Exact_predicates_inexact_constructions_kernel but that doesn't work given
>> that the precision problem.
>>
>>
>> Here is my code :
>>
>> #include &lt;CGAL/Arrangement_2.h&gt;
>> #include &lt;CGAL/Arr_segment_traits_2.h&gt;
>> #include &lt;CGAL/Arr_linear_traits_2.h&gt;
>> #include &lt;CGAL/Exact_predicates_exact_constructions_kernel.h&gt;
>> #include &lt;CGAL/Exact_predicates_inexact_constructions_kernel.h&gt;
>> #include &lt;CGAL/Arr_extended_dcel.h&gt;
>>
>> typedef CGAL::Exact_predicates_inexact_constructions_kernel
>> Kernel1;
>> typedef CGAL::Exact_predicates_exact_constructions_kernel
>> Kernel2;
>> typedef CGAL::Arr_linear_traits_2
> <Kernel2>
>> Traits;
>> typedef CGAL::Arr_face_extended_dcel&lt;Traits, bool&gt;
>> Dcel_2;
>> typedef CGAL::Arrangement_2&lt;Traits, Dcel_2&gt;
>> Arrangement;
>>
>>
>> int main()
>> {
>> // Initialize segments distance and segments number of points
>> double distance = 1;
>> size_t nbPoints = 100;
>>
>> // Fill the three points vectors representing the three lines
>>
>> std::vector&lt;std::vector&amp;lt;CGAL::Point_2&amp;lt;Kernel1&gt;>>
>> lines_points;
>> lines_points.resize(3);
>> double x = 0;
>> for (size_t i = 0; i < nbPoints; i++, x += distance / nbPoints) {
>> lines_points.at(0).push_back(CGAL::Point_2
> <Kernel1>
> (distance
>> - x, x));
>> lines_points.at(1).push_back(CGAL::Point_2
> <Kernel1>
> (x,
>> x));
>> lines_points.at(2).push_back(CGAL::Point_2
> <Kernel1>
> (x,
>> distance / 2));
>> }
>>
>> // Fit for each points vector a line using
>> linear_least_squares_fitting_2
>> // and transform this line in segment with
>> Exact_predicates_exact_constructions_kernel
>> CGAL::Line_2
> <Kernel1>
> line;
>> std::vector&lt;CGAL::Segment_2&amp;lt;Kernel2&gt;>
>> segments(lines_points.size());
>> for (size_t i = 0; i < lines_points.size(); i++) {
>> CGAL::linear_least_squares_fitting_2(lines_points.at
>> (i).begin(),
>> lines_points.at(i).end(), line, CGAL::Dimension_tag<0>());
>> segments.at(i) =
>> CGAL::Segment_2
> <Kernel2>
> (CGAL::Point_2
> <Kernel2>
> (0,
>> -line.c() / line.b()),
>> CGAL::Point_2
> <Kernel2>
> (distance, -(distance *
>> line.a() + line.c()) /
>> line.b()));
>> }
>>
>> // Put the processed segment in an arrangement
>> Arrangement arr;
>> CGAL::insert(arr, segments.begin(), segments.end());
>>
>> // Print the number of bounded face
>> std::cout << arr.number_of_faces() -
>> arr.number_of_unbounded_faces() <<
>> std::endl;
>>
>> // Print the bounded face of the arrangement
>> Arrangement::Ccb_halfedge_const_circulator curr;
>> for (Arrangement::Face_const_handle fit = arr.faces_begin(); fit
>> !=
>> arr.faces_end(); ++fit) {
>> if (!fit->is_unbounded()) {
>> curr = fit->outer_ccb();
>> do {
>> std::cout << curr->source()->point() << "
>> - ";
>> } while (++curr != fit->outer_ccb());
>> }
>> }
>> }
>>
>>
>>
>> Is there a Kernel that provide against this problem?
>>
>> Thank you very much.
>> Regards.
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://cgal-discuss.949826.n4.nabble.com/Create-a-correct-arrangement-with-lines-processed-with-linear-least-squares-fitting-2-function-tp4661426.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
>>
>>
>>
>
> --
> 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/Create-a-correct-arrangement-with-lines-processed-with-linear-least-squares-fitting-2-function-tp4661426p4661435.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.18.

Top of Page