Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] Question about linear_least_squares_fitting_3
- Date: Fri, 06 Apr 2012 11:02:20 +0200
can you provide the .cpp as attachement, nabble is eating some special characters.
Sebastien.
On 04/03/2012 06:52 PM, edward wrote:
Hi everyone,
The function linear_least_squares_fitting_3 to estimate best fitting plane
seems to obtain unexpected results when the points are generated from a
specific plane.
I randomly constructed a plane and then retrived some points from this
plane. Another new plane is estiamted by these points utilizing funtion
linear_least_squares_fitting_3. But these two planes are not the same!
Here are main codes:
boost::mt19937 eng; // a core engine class:Mersenne
eng.seed(time(NULL));
boost::uniform_real<> unif01(-1,1); //<>不可少
boost::uniform_real<> unif100(-100,100);
boost::variate_generator<boost::mt19937&, boost::uniform_real<>
>
random01(eng, unif01);
boost::variate_generator<boost::mt19937&, boost::uniform_real<>
>
random100(eng, unif100);
Plane_3 plane(random01(),random01(),random01(),random100());
cout<<"Origin plane"<<plane<<endl;
list<Point_3> pts;
int N=10;
for(int i=0;i<N;++i)
{
double x, y,z;
x=random100();
y=random100();
xy2z(plane,x,y,z);//User defined function, from x or y to
retrive z from
plane
pts.push_back(Point_3(x,y,z));
}
for(list<Point_3>::iterator
iter=pts.begin();iter!=pts.end();++iter)
{
cout<<"Point to Plane Dist"<<CGAL::squared_distance(*iter,
plane)<<endl;
}
Plane_3 plane1;
cout<<endl;
cout<<"CGAL Fitting result"<<
CGAL::linear_least_squares_fitting_3(pts.begin(),pts.end(),plane1,
CGAL::Dimension_tag<0>());
cout<<endl;
cout<<"cgal plane"<<plane1<<endl;
for(list<Point_3>::iterator
iter=pts.begin();iter!=pts.end();++iter)
{
//cout<<*iter<<endl;
cout<<"Point to Plane Dist
"<<CGAL::squared_distance(*iter, plane1)<<endl;
}
The output is:
Origin plane<b>-0.456603 0.437936 -0.276328 -49.6504*
Point to Plane Dist 0
Point to Plane Dist 0
Point to Plane Dist 4.23699e-028
Point to Plane Dist 0
Point to Plane Dist 0
Point to Plane Dist 0
Point to Plane Dist 1.65507e-030
Point to Plane Dist 1.6948e-027
Point to Plane Dist 0
Point to Plane Dist 0
CGAL Fitting result 1
cgal plane *-0.661375 0.634336 -0.400252 -71.917*
Point to Plane Dist 1.01102e-017
Point to Plane Dist 2.73393e-018
Point to Plane Dist 9.74678e-018
Point to Plane Dist 1.0964e-015
Point to Plane Dist 6.0825e-016
Point to Plane Dist 1.66278e-016
Point to Plane Dist 1.23536e-015
Point to Plane Dist 2.27407e-016
Point to Plane Dist 2.63125e-018
Point to Plane Dist 3.43804e-016
Press any key to continue . . .
It seems that the fitting results, point to plane squared distance is good,
but plane equation are quite different. How does this happens?
Hope you could help
Best regards
Edward
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Question-about-linear-least-squares-fitting-3-tp4529464p4529464.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Question about linear_least_squares_fitting_3, edward, 04/03/2012
- Re: [cgal-discuss] Question about linear_least_squares_fitting_3, Sebastien Loriot (GeometryFactory), 04/06/2012
Archive powered by MHonArc 2.6.16.