我试图通过使用循环来强制旋转矩阵。基本上我在两个不同的坐标系中有一堆点(准确地说是 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)之间给出了最小幅度的差异......这应该在旋转矩阵之后实现。唯一的问题是在我拥有的东西和确定该值之间有一个转换的中间步骤。
关于如何在坐标系之间找到近似平移值的任何想法?我正在考虑对所有值进行平均以获得平均翻译,但我不确定如何去做。
非常感谢任何其他提示,谢谢!