linear_least_squares_fitting_3() gives bad fitting quality for input of only 3 points

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

linear_least_squares_fitting_3() gives bad fitting quality for input of only 3 points

Leon Nan
Hi all,

I am using CGAL::linear_least_squares_fitting_3() to fit planes from point set. It works pretty well for data set with more than 3 points. But I was surprised that this function behaved when fitting a plane form 3 points. The function returned 0.495031, which meant the variance orthogonally to the fitting plane was quite big. Acutally 1.0 is expected because 3 points are exactlly in the same plane. Can someone explain?

Here is the code I call the fitting function:
                Plane3f plane;
                double q = CGAL::linear_least_squares_fitting_3(
                        pts.begin(),
                        pts.end(),
                        plane,
                        CGAL::Dimension_tag<0>()
                        );


And the input(only 3 points):
        ==================================
                86.1817 3075.31 1031.53
                164.575 3075.31 913.936
                754.546 0 28.9401
        ==================================

--
Leon
http://web.siat.ac.cn/~liangliang/


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

Reply | Threaded
Open this post in threaded view
|

Re: linear_least_squares_fitting_3() gives bad fitting quality for input of only 3 points

Pierre Alliez-2
dear Leon,

thank you for discussing this bug.
I think the problem comes from the eigenvalue computation.

we will dig this out.

in the meantime I invite you to replace the code which computes the
eigenvalues/vectors by
calls to the eigen library, and report whay you get here in this list.

thank you,

Pierre



Le 21/09/2011 08:13, Leon Nan a écrit :

> Hi all,
>
> I am using CGAL::linear_least_squares_fitting_3() to fit planes from point set. It works pretty well for data set with more than 3 points. But I was surprised that this function behaved when fitting a plane form 3 points. The function returned 0.495031, which meant the variance orthogonally to the fitting plane was quite big. Acutally 1.0 is expected because 3 points are exactlly in the same plane. Can someone explain?
>
> Here is the code I call the fitting function:
>                 Plane3f plane;
> double q = CGAL::linear_least_squares_fitting_3(
> pts.begin(),
> pts.end(),
> plane,
> CGAL::Dimension_tag<0>()
> );
>
>
> And the input(only 3 points):
> ==================================
> 86.1817 3075.31 1031.53
> 164.575 3075.31 913.936
> 754.546 0 28.9401
> ==================================
>
> --
> Leon
> http://web.siat.ac.cn/~liangliang/
>
>



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

Reply | Threaded
Open this post in threaded view
|

Re: linear_least_squares_fitting_3() gives bad fitting quality for input of only 3 points

Gael Guennebaud
In reply to this post by Leon Nan
This is because the default tolerance value in eigen.h is much too
high. Setting it to:

static const FT EPSILON = std::numeric_limits<FT>::epsilon();

fix the issue.

gael

2011/9/23 Pierre Alliez <[hidden email]>:

> dear Leon,
>
> thank you for discussing this bug.
> I think the problem comes from the eigenvalue computation.
>
> we will dig this out.
>
> in the meantime I invite you to replace the code which computes the
> eigenvalues/vectors by
> calls to the eigen library, and report whay you get here in this list.
>
> thank you,
>
> Pierre
>
>
>
> Le 21/09/2011 08:13, Leon Nan a écrit :
>> Hi all,
>>
>> I am using CGAL::linear_least_squares_fitting_3() to fit planes from point set. It works pretty well for data set with more than 3 points. But I was surprised that this function behaved when fitting a plane form 3 points. The function returned 0.495031, which meant the variance orthogonally to the fitting plane was quite big. Acutally 1.0 is expected because 3 points are exactlly in the same plane. Can someone explain?
>>
>> Here is the code I call the fitting function:
>>                 Plane3f plane;
>>               double q = CGAL::linear_least_squares_fitting_3(
>>                       pts.begin(),
>>                       pts.end(),
>>                       plane,
>>                       CGAL::Dimension_tag<0>()
>>                       );
>>
>>
>> And the input(only 3 points):
>>       ==================================
>>               86.1817 3075.31 1031.53
>>               164.575 3075.31 913.936
>>               754.546 0 28.9401
>>       ==================================
>>
>> --
>> Leon
>> http://web.siat.ac.cn/~liangliang/
>>
>>
>
>
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>
>

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

Reply | Threaded
Open this post in threaded view
|

Re: linear_least_squares_fitting_3() gives bad fitting quality for input of only 3 points

Leon Nan
Thank you Gael for pointing out the reason.
The fitting quality was improved a lot for those 3 points (from 0.495031 to 1.0000011) by setting the EPSILON in eigen.h to std::numeric_limits<FT>::epsilon().
 
So... Pierre, this is not a bug, just a parameter issue. Perhaps making the "EPSILON" a parameter in the function will be more convienent for users. 
 
Thank you again!
 
--
Leon
 

 
2011/9/25 Gael Guennebaud <[hidden email]>
This is because the default tolerance value in eigen.h is much too
high. Setting it to:

static const FT EPSILON = std::numeric_limits<FT>::epsilon();

fix the issue.

gael

2011/9/23 Pierre Alliez <[hidden email]>:
> dear Leon,
>
> thank you for discussing this bug.
> I think the problem comes from the eigenvalue computation.
>
> we will dig this out.
>
> in the meantime I invite you to replace the code which computes the
> eigenvalues/vectors by
> calls to the eigen library, and report whay you get here in this list.
>
> thank you,
>
> Pierre
>
>
>
> Le 21/09/2011 08:13, Leon Nan a écrit :
>> Hi all,
>>
>> I am using CGAL::linear_least_squares_fitting_3() to fit planes from point set. It works pretty well for data set with more than 3 points. But I was surprised that this function behaved when fitting a plane form 3 points. The function returned 0.495031, which meant the variance orthogonally to the fitting plane was quite big. Acutally 1.0 is expected because 3 points are exactlly in the same plane. Can someone explain?
>>
>> Here is the code I call the fitting function:
>>                 Plane3f plane;
>>               double q = CGAL::linear_least_squares_fitting_3(
>>                       pts.begin(),
>>                       pts.end(),
>>                       plane,
>>                       CGAL::Dimension_tag<0>()
>>                       );
>>
>>
>> And the input(only 3 points):
>>       ==================================
>>               86.1817 3075.31 1031.53
>>               164.575 3075.31 913.936
>>               754.546 0 28.9401
>>       ==================================
>>
>> --
>> Leon
>> http://web.siat.ac.cn/~liangliang/
>>
>>
>
>
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>
>

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