已知器械A和器械B在同一坐标系,且为刚性连接(器械A与器械B初始位姿矩阵为matrixA、matrixB),已知器械B移动到某一个位置后得到matrixB1,计算器械A当前的位姿矩阵。
// matrixA和matrixB为已知位姿矩阵
vtkSmartPointer<vtkMatrix4x4> matrixA;
vtkSmartPointer<vtkMatrix4x4> matrixB;
vtkSmartPointer<vtkMatrix4x4> transMatrixB = vtkSmartPointer<vtkMatrix4x4>::New();
transMatrixB->Identity();
// 首先计算器械B初始位置与当前位置之间的旋转矩阵
matrixB1->Invert();
vtkMatrix4x4::Multiply4x4(matrixB1, matrixB, transMatrixB);
// 计算得出当前器械A位姿矩阵
vtkSmartPointer<vtkMatrix4x4> MatrixA1 = vtkSmartPointer<vtkMatrix4x4>::New();
MatrixA1->Identity();
vtkMatrix4x4::Multiply4x4(transMatrixB, matrixA, MatrixA1);
已知器械A和器械C在同一坐标系下且为刚性连接,将器械A转换至器械C坐标系下求转换矩阵
mitk::AffineTransform3D::Pointer bonetransformA = mitk::AffineTransform3D::new();
bonetransformA->SetMatrix(matrixA);
bonetransformA->SetOffset(offsetA);
// 将器械C位姿矩阵求逆
matrixC->Invert();
mitk::AffineTransform3D::Pointer bonetransformC = mitk::AffineTransform3D::new();
bonetransformC->SetMatrix(matrixC);
bonetransformC->SetOffset(offsetC);
// 计算器械A与器械C的转换关系 A-->C
mitk::AffineTransform3D::Pointer combineTransform = mitk::AffineTransform3D::new();
combineTransform->Compose(bonetransformA);
combineTransform->Compose(bonetransformC);
// 将A--->C 转换为 C--->A ToolHead2ImageHeadMatrix
mitk::AffineTransform3D::Pointer combineTransformInvers = mitk::AffineTransform3D::new();
combineTransform->GetInverse(combineTransformInvers);