19 #include <vnl/vnl_least_squares_function.h>
27 const std::vector<a_point> & cloud) :
31 void f(
const vnl_vector<double>& x, vnl_vector<double>& fx);
39 a_point
dir(x[0],x[1],x[2]);
40 a_point orig(x[3],x[4],x[5]);
46 for (
int i = 0; i< fx.size(); i++)
54 o <<
"***************" << std::endl;
55 o <<
"a_shape_circle:" << std::endl;
56 o <<
"***************" << std::endl;
57 o <<
"This is a 'circle' fitting class" << std::endl;
68 if (
dir.norm()==0)
return;
69 this->
dir(dir.normalise());
70 a_point ce = circle_centre(p1,p2,p3);
72 this->
radius(((p1-ce).norm()+(p2-ce).norm()+(p3-ce).norm())/3.);
77 a_point d =
pt-this->
orig();
78 a_point pv = this->
dir()*(this->
dir()*d);
79 double dv = pv.norm();
80 a_point ph = (d-pv).normalise();
86 a_point d =
pt-this->
orig();
87 a_point pv = this->
dir()*(this->
dir()*d);
88 double dv = pv.norm();
90 double dh = ph.norm()-this->
radius();
91 return sqrt(dh*dh+dv*dv);
107 }
while ((i1==i3)||(i2==i3));
108 a_point p1 = pts[i1];
109 a_point p2 = pts[i2];
110 a_point p3 = pts[i3];
111 this->
p3pts(p1,p2,p3);
116 std::vector<a_point> pts2;
117 int cs0 = pts.size();
121 std::cerr <<
"current estimate:" << std::endl;
122 std::cerr <<
"c: " << this->
orig() << std::endl;
123 std::cerr <<
"n: " << this->
dir() << std::endl;
124 std::cerr <<
"r: " << this->
radius() << std::endl;
136 const double pi2 = 2*3.14159265358979;
137 a_point ce = this->
orig();
138 a_point nz = this->
dir();
140 if (fabs(nz.x())>fabs(nz.y()))
141 p = a_point(0.,1.,0.);
143 p = a_point(1.,0.,0.);
146 std::cout << nseg << std::endl;
147 for (
int i = 0; i<nseg; i++)
149 double a = i*pi2/nseg;
152 a_point
n = ce+nx*c+ny*s;
153 std::cout <<
n << std::endl;
159 const double pi2 = 2*3.14159265358979;
160 a_point ce = this->
orig();
161 a_point nz = this->
dir();
163 if (fabs(nz.x())>fabs(nz.y()))
164 p = a_point(0.,1.,0.);
166 p = a_point(1.,0.,0.);
171 std::cout << nseg << std::endl;
172 for (
int i = 1; i<nseg; i++)
174 double a = i*pi2/nseg;
178 std::cout << n0 <<
" " <<
n << std::endl;
182 std::cout <<
n <<
" " << n0 << std::endl;
a_shape_circle_function(a_shape_circle &shape, const std::vector< a_point > &cloud)
void f(const vnl_vector< double > &x, vnl_vector< double > &fx)
const std::vector< a_point > & cloud_
void export_points(const unsigned int nseg, const std::vector< a_point > &pts) const
void export_lines(const unsigned int nseg, const std::vector< a_point > &pts) const
double dist_point(const a_point p) const
void fit_cloud(std::vector< a_point > &pts, short nl=1)
a_point closest_point(const a_point p) const
void random_hint(const std::vector< a_point > &pts)
void p3pts(const a_point p1, const a_point p2, const a_point p3)
static const std::string help()
void fit_cloud(const std::vector< a_point > &pts, vnl_least_squares_function &fn)
static const std::string help()
int best_fitting_cloud(const std::vector< a_point > &pts, std::vector< a_point > &pts2)
e_point cross(e_point &a, e_point &b)
a_point dir(int i, int l)