The affine transform in the 3D world can be represented by a 4×4 matrix.
If there is no scale in the affine transform, the vector is translate vector and A is the rotate matrix.
The original point’s position is representing by M, the changed point’s position is M’.
#define vtkSPtr vtkSmartPointer
#define vtkSPtrNew(Var, Type) vtkSPtr<Type> Var = vtkSPtr<Type>::New();
using namespace std;
int main()
{
vtkSPtrNew( trans, vtkTransform );
trans->RotateX( 30 );
trans->Translate( 0, 3, 2 );
//trans->Scale( 2, 3, 4 );
trans->Translate( 1, 0, 0 );
trans->RotateY( 45 );
//trans->Scale( 2, 3, 4 );
trans->Update();
trans->PrintSelf( std::cout, vtkIndent() );
vtkSPtrNew( moveTrans, vtkTransform );
moveTrans->Translate( 1, 1.59808, 3.23205 );
moveTrans->Update();
moveTrans->PrintSelf( std::cout, vtkIndent() );
double elements[16] = {
0.707107 ,0 ,0.707107 ,0,
0.353553 ,0.866025 ,-0.353553 ,0,
-0.612372 ,0.5 ,0.612372 ,0,
0 ,0 ,0 ,1
};
vtkSPtrNew( rotateTrans, vtkTransform );
rotateTrans->SetMatrix( elements );
rotateTrans->Update();
vtkSPtrNew( testTrans, vtkTransform );
testTrans->Concatenate( moveTrans );
testTrans->Concatenate( rotateTrans );
testTrans->Update();
testTrans->PrintSelf( std::cout, vtkIndent() ); //the matrix is same with the trans's.
return 0;
}
/*
0.707107 0 0.707107 1
0.353553 0.866025 -0.353553 1.59808
-0.612372 0.5 0.612372 3.23205
0 0 0 1
*/