Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Objekte fürs lineare Gleichungssystem: m*x = b, Lösung kommt in x.
- Mat m, x, b;
- int dim = 3; // the computing dimension (e.g. 3 for X, Y, Z)
- std::stringstream txtDebug;
- // init matrices
- m = Mat(dim*iN, dim+1, CV_64FC1, double(0));
- x = Mat(dim+iN, 1, CV_64FC1, double(0));
- b = Mat(dim*iN, 1, CV_64FC1, double(0));
- // fill matrices with known information
- for (int i=0;i<iN;i++)
- for (int j=0;j<dim;j++)
- {
- m.at<double>(i*dim+j,j) = 1.0;
- m.at<double>(i*dim+j,dim) = (-1) * matDir.at<double>(j,i);
- b.at<double>(i*dim+j,0) = matPoint.at<double>(j,i);
- }
- // get inverse of m and solve equation
- x = m.inv(DECOMP_SVD) * b;
- // debug
- for (int i=0;i<x.rows;i++)
- {
- for (int j=0;j<x.cols;j++)
- {
- txtDebug << " " << x.at<double>(i,j) << "; "; // In die Output Edit Box des Dialogs
- //if (i%4 == 0)
- }
- txtDebug << "\r\n";
- }
- txtOut.Format("%s",txtDebug.str().c_str());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement