Rev 172 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 172 | Rev 181 | ||
---|---|---|---|
Line 220... | Line 220... | ||
220 | { |
220 | { |
221 | double accx = 0, accy = 0, accxy = 0, accx2 = 0; |
221 | double accx = 0, accy = 0, accxy = 0, accx2 = 0; |
222 | double A, B; |
222 | double A, B; |
223 | double esty; |
223 | double esty; |
224 | 224 | ||
- | 225 | // printf("PointEstimate points: "); |
|
225 | for(int i = 0; i < nrp; i++) |
226 | for(int i = 0; i < nrp; i++) |
226 | { |
227 | { |
- | 228 | // printf("[%lf,%lf], ", points[2*i], points[2*i+1]); |
|
227 | accx += points[2*i]; |
229 | accx += points[2*i]; |
228 | accy += points[2*i+1]; |
230 | accy += points[2*i+1]; |
229 | accxy += points[2*i]*points[2*i+1]; |
231 | accxy += points[2*i]*points[2*i+1]; |
230 | accx2 += points[2*i]*points[2*i]; |
232 | accx2 += points[2*i]*points[2*i]; |
231 | } |
233 | } |
- | 234 | // printf("\n"); |
|
232 | 235 | ||
233 | A = (accx2*accy - accx*accxy)/(nrp*accx2 - accx*accx); |
236 | A = (accx2*accy - accx*accxy)/(nrp*accx2 - accx*accx); |
234 | B = (nrp*accxy - accx*accy)/(nrp*accx2 - accx*accx); |
237 | B = (nrp*accxy - accx*accy)/(nrp*accx2 - accx*accx); |
- | 238 | ||
- | 239 | // printf("Fiting function = %lf + %lf*x\n", A, B); |
|
235 | 240 | ||
236 | esty = A + B*points[2*nrp]; |
241 | esty = A + B*points[2*nrp]; |
237 | 242 | ||
238 | if(DBGSIG) printf("PointEstimate(): A = %lf, B = %lf, estimate = %lf, real = %lf, error = %lf\n", A, B, esty, points[2*nrp+1], abs(esty - points[2*nrp+1])/points[2*nrp+1]); |
243 | if(DBGSIG) printf("PointEstimate(): A = %lf, B = %lf, estimate = %lf, real = %lf, error = %lf\n", A, B, esty, points[2*nrp+1], abs(esty - points[2*nrp+1])/points[2*nrp+1]); |
239 | 244 |