Recently I used the Transform module in Slicer to apply a linear transformation. Let’s say the translation is [10, 20, 30]. And the model moved to the correct position.
However, when I used my own vtk codes below, the result is not correct.
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
transform->Translate(10, 20, 30);
vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transformFilter->SetInputData(mesh);
transformFilter->SetTransform(transform);
transformFilter->Update();
First I was thinking it is because of the coordinate system difference (RAS and LPS), so I flipped the two axes:
translationMatrix->SetElement(0, 0, -1.0);
translationMatrix->SetElement(1, 1, -1.0);
However, it is still not correct. Did I miss some steps? Thanks for any suggestions!