We can use vtkTransform’s function concatenate to do matrix multiplication.
There are three matrix which have the mathematical relationship.
It’s equivalent to the following code.
vtkSPtrNew( C, vtkTransform );
C->Concatenate(B);
C->Concatenate(A);
C->Update();
The experimental code:
#include <iostream>
#include <vtkSmartPointer.h>
#include <vtkTransform.h>
#define vtkSPtr vtkSmartPointer
#define vtkSPtrNew(Var, Type) vtkSPtr<Type> Var = vtkSPtr<Type>::New();
using namespace std;
int main()
{
// B*A = C
vtkSPtrNew( A, vtkTransform );
double elementsA[16] = { 1, 0, 0, 1,
0, 1, 0, 1,
0, 0, 1, 0,
0, 0, 0, 1 };
A->SetMatrix( elementsA );
vtkSPtrNew( B, vtkTransform );
double elementsB[16] = { 1, 0, 0, 0,
0, 0.939693, -0.34202, 0,
0, 0.34202, 0.939693, 0,
0, 0, 0, 1 };
B->SetMatrix( elementsB );
vtkSPtrNew( C, vtkTransform );
C->Concatenate(B);
C->Concatenate(A);
C->Update();
C->PrintSelf( std::cout, vtkIndent() );
return 0;
}