我正试图通过使用循环来强制旋转矩阵。基本上我在两个不同的坐标系中有一堆点(确切地说是6个),我想尝试一组具有不同的欧拉角值的旋转矩阵,以便找到点之间的匹配。我的大问题是,这个坐标转换也涉及到翻译。这就是让我陷入困境的那一部分。这是我的尝试
%Point 1 (Between two front teeth)
Vector_Endo1 = [-8.9329*voxTommConversion;8.5058*voxTommConversion;117.7193*voxTommConversion];
voxPoint1 = [418.7801;41.3845;231.3922];
%Point 2 (Mid-left skull, portruding bone on bottom)
Vector_Endo2 = [-11.2102*voxTommConversion;112.4456*voxTommConversion;61.3865*voxTommConversion];
voxPoint2 = [444;275.3698;99.7672];
%Point 3 (Cavity on top, front, middle, right of head, pointed section)
Vector_Endo3 = [140.0249*voxTommConversion;95.0548*voxTommConversion;148.9631*voxTommConversion];
voxPoint3 = [79.6156;255.4725;259.3405];
%Point 4 (Between two molars on left side)
Vector_Endo4 = [-9.4742*voxTommConversion;42.4474*voxTommConversion;87.0998*voxTommConversion];
voxPoint4 = [428.7617;118.7252;158.994];
%Point 5 (Left large stub inside of head)
Vector_Endo5 = [42.2453*voxTommConversion;85.6763*voxTommConversion;105.5044*voxTommConversion];
voxPoint5 = [309.3354;221.2764;187.5172];
%Point 6 (Thin portruding point underneath right side of skull)
Vector_Endo6 = [1.3304*voxTommConversion;101.7924*voxTommConversion;157.7978*voxTommConversion];
voxPoint6 = [390.7929;259.3982;311.4098];
allPoints=[Vector_Endo1,Vector_Endo2,Vector_Endo3,Vector_Endo4,Vector_Endo5,Vector_Endo6];
%testVector is used to compare difference between computed offset and real offset
for Rx=0:pi/180:2*pi,
for Ry=0:pi/180:2*pi,
for Rz=0:pi/180:2*pi,
for points = 1:length(allPoints)
testVector=euler2rotmat(Rx,Ry,Rz)*allPoints(:,points);
allTestVectors(:,i)=testVector;
我认为应该给我所有需要的旋转矩阵(达到某种近似值)。我将继续制作一些代码,找到旋转矩阵,使我的测试向量和真实点(allPointsVox)之间的最小幅度不同....这应该在旋转矩阵之后实现。唯一的问题是在我拥有和确定价值之间存在一个中间步骤。
有关如何在坐标系之间找到近似平移值的任何想法?我正在考虑对所有值进行平均以获得平均翻译,但我不确定如何去做。
非常感谢任何其他提示,谢谢!
答案 0 :(得分:3)
您可以从每组中减去点coloud的质心,从而消除了平移效果。