16 return (
int)(
max*(rand()/(RAND_MAX+1.0)));
21 return min + (rand() / (double)RAND_MAX) * (
max -
min);
38 do { r = drand48(); }
while (r == 0.0);
40 do { r = drand48(); }
while (r == 0.0);
41 x2 = 2.0 * drand48() - 1.0;
43 }
while(w > 1.0 || w==0.0);
45 return(sigma * x2 * sqrt(-2.0*log(w)/w));
71 return exp(-.5*
delta*
delta/sigmaSquare)/sqrt(2*M_PI*sigmaSquare);
78 return -.5*
delta*
delta/sigmaSquare-.5*log(2*M_PI*sigmaSquare);
99 static gsl_eigen_symmv_workspace * m_eigenspace=NULL;
100 static gsl_matrix * m_cmat=NULL;
101 static gsl_matrix * m_evec=NULL;
102 static gsl_vector * m_eval=NULL;
103 static gsl_vector * m_noise=NULL;
104 static gsl_vector * m_pnoise=NULL;
106 if (m_eigenspace==NULL){
107 m_eigenspace=gsl_eigen_symmv_alloc(3);
108 m_cmat=gsl_matrix_alloc(3,3);
109 m_evec=gsl_matrix_alloc(3,3);
110 m_eval=gsl_vector_alloc(3);
111 m_noise=gsl_vector_alloc(3);
112 m_pnoise=gsl_vector_alloc(3);
115 gsl_matrix_set(m_cmat,0,0,cov.xx); gsl_matrix_set(m_cmat,0,1,cov.xy); gsl_matrix_set(m_cmat,0,2,cov.xt);
116 gsl_matrix_set(m_cmat,1,0,cov.xy); gsl_matrix_set(m_cmat,1,1,cov.yy); gsl_matrix_set(m_cmat,1,2,cov.yt);
117 gsl_matrix_set(m_cmat,2,0,cov.xt); gsl_matrix_set(m_cmat,2,1,cov.yt); gsl_matrix_set(m_cmat,2,2,cov.tt);
118 gsl_eigen_symmv (m_cmat, m_eval, m_evec, m_eigenspace);
119 for (
int i=0; i<3; i++){
120 eval[i]=gsl_vector_get(m_eval,i);
121 for (
int j=0; j<3; j++)
122 evec[i][j]=gsl_matrix_get(m_evec,i,j);
127 static gsl_matrix * m_rmat=NULL;
128 static gsl_matrix * m_vmat=NULL;
129 static gsl_matrix * m_result=NULL;
131 m_rmat=gsl_matrix_alloc(3,3);
132 m_vmat=gsl_matrix_alloc(3,3);
133 m_result=gsl_matrix_alloc(3,3);
138 gsl_matrix_set(m_rmat,0,0,
c ); gsl_matrix_set(m_rmat,0,1, -s); gsl_matrix_set(m_rmat,0,2, 0.);
139 gsl_matrix_set(m_rmat,1,0, s ); gsl_matrix_set(m_rmat,1,1,
c); gsl_matrix_set(m_rmat,1,2, 0.);
140 gsl_matrix_set(m_rmat,2,0, 0.); gsl_matrix_set(m_rmat,2,1, 0.); gsl_matrix_set(m_rmat,2,2, 1.);
142 for (
unsigned int i=0; i<3; i++)
143 for (
unsigned int j=0; j<3; j++)
144 gsl_matrix_set(m_vmat,i,j,
evec[i][j]);
145 gsl_blas_dgemm (CblasNoTrans, CblasNoTrans, 1., m_rmat, m_vmat, 0., m_result);
147 for (
int i=0; i<3; i++){
148 for (
int j=0; j<3; j++)
149 ecov.evec[i][j]=gsl_matrix_get(m_result,i,j);
155 static gsl_matrix * m_evec=NULL;
156 static gsl_vector * m_noise=NULL;
157 static gsl_vector * m_pnoise=NULL;
159 m_evec=gsl_matrix_alloc(3,3);
160 m_noise=gsl_vector_alloc(3);
161 m_pnoise=gsl_vector_alloc(3);
163 for (
int i=0; i<3; i++){
164 for (
int j=0; j<3; j++)
165 gsl_matrix_set(m_evec,i,j,
evec[i][j]);
167 for (
int i=0; i<3; i++){
171 gsl_vector_set(m_pnoise,i, v);
173 gsl_blas_dgemv (CblasNoTrans, 1., m_evec, m_pnoise, 0, m_noise);
174 OrientedPoint ret(gsl_vector_get(m_noise,0),gsl_vector_get(m_noise,1),gsl_vector_get(m_noise,2));
175 ret.theta=atan2(sin(ret.theta), cos(ret.theta));
196 std::vector<double>::const_iterator w=weights.begin();
197 for (std::vector<OrientedPoint>::const_iterator p=poses.begin(); p!=poses.end(); p++){
213 for (std::vector<OrientedPoint>::const_iterator p=poses.begin(); p!=poses.end(); p++){
230 EigenCovariance3 ecov(
cov);
240 for (std::vector<OrientedPoint>::const_iterator p=poses.begin(); p!=poses.end(); p++){
254 for (std::vector<OrientedPoint>::const_iterator p=poses.begin(); p!=poses.end(); p++){
270 EigenCovariance3 ecov(
cov);