已知平面坐标系:0.0238753x - 0.0278248y + 0.999328z - 1.72128*10^(-6) = 0
n_z_init=[0.0238753;-0.0278248;0.999328]; //平面法向量
plane_d=-1.72128*10^(-6);
P1_z=-plane_d/n_z_init(3);
P2_z=(-plane_d-10*n_z_init(1))/n_z_init(3);
Point1_g=[0;0;P1_z]; //求平面上第一个已知点
Point2_g=[10;0;P2_z]; //求平面上第二个已知点
n_x_init=[Point2_g-Point1_g];
n_y_init=cross(n_z_init,n_x_init);
n_x=n_x_init/norm(n_x_init);
n_y=n_y_init/norm(n_y_init);
n_z=-n_z_init/norm(n_z_init); //z轴方向取反加负号
R=[n_x n_y n_z];
R=R';
T=-R*Point1_g; //R为旋转矩阵,T为平移矩阵
/*根据已知平面方程,建立坐标系,并计算该坐标系与世界坐标系的关系*/
/*已知平面坐标系:0.0238753x - 0.0278248y + 0.999328z - 1.72128*10^(-6) = 0*/
Mat n_z_init = (Mat_<double>(3, 1) << 0.0238753, -0.0278248, 0.999328);
double plane_d = -1.72128e-6;
double P1_z = -plane_d / n_z_init.at<double>(2, 0);
double P2_z = (-plane_d - 10 * n_z_init.at<double>(0, 0)) / n_z_init.at<double>(2, 0);
Mat Point1 = (Mat_<double>(3, 1) << 0, 0, P1_z);
Mat Point2 = (Mat_<double>(3, 1) << 10, 0, P2_z);
Mat n_x_init = Point2 - Point1;
Mat n_y_init = (Mat_<double>(3, 1) << n_z_init.at<double>(1, 0) * n_x_init.at<double>(2, 0) - n_z_init.at<double>(2, 0) * n_x_init.at<double>(1, 0),
n_z_init.at<double>(2, 0) * n_x_init.at<double>(0, 0) - n_z_init.at<double>(0, 0) * n_x_init.at<double>(2, 0),
n_z_init.at<double>(0, 0) * n_x_init.at<double>(1, 0) - n_z_init.at<double>(1, 0) * n_x_init.at<double>(0, 0));
Mat xcopy = n_x_init.clone();
double xnorm = norm(xcopy);
Mat n_x = (Mat_<double>(1, 3) << n_x_init.at<double>(0, 0) / norm(n_x_init), n_x_init.at<double>(1, 0) / norm(n_x_init), n_x_init.at<double>(2, 0) / norm(n_x_init));
Mat n_y = (Mat_<double>(1, 3) << n_y_init.at<double>(0, 0) / norm(n_y_init), n_y_init.at<double>(1, 0) / norm(n_y_init), n_y_init.at<double>(2, 0) / norm(n_y_init));
Mat n_z = (Mat_<double>(1, 3) << -n_z_init.at<double>(0, 0) / norm(n_z_init), -n_z_init.at<double>(1, 0) / norm(n_z_init), -n_z_init.at<double>(2, 0) / norm(n_z_init));
Mat R;
R = Mat::zeros(3, 3, CV_64FC1);
n_x.row(0).copyTo(R.row(0));
n_y.row(0).copyTo(R.row(1));
n_z.row(0).copyTo(R.row(2));
Mat T = -R * Point1;