I write the reason why concatenate transform and its inversed transform for offTrans in scale operation based on the article Rotate, Translate And Scale For Camera

    vtkSPtrNew( scaleTrans, vtkTransform );
    scaleTrans->Scale( factor, factor, 1 );
    scaleTrans->Update();

    vtkSPtrNew( offTrans, vtkTransform );
    offTrans->Concatenate( worldTrans );
    offTrans->Concatenate( scaleTrans );
    offTrans->Concatenate( worldInversedTrans );
    offTrans->Update();
    PointStruct line( 1, 0, 0 );
    offTrans->TransformVector( line.point, line.point );
    cout << "line: " << line;

We got the following result when zooming in or zoom out after rotating the image.

line: PointStruct [0.847532, -5.80018e-05, 0.0566997]
line: PointStruct [0.847532, -5.80018e-05, 0.0566997]
line: PointStruct [1.18449, 7.01822e-05, -0.0686066]
line: PointStruct [1.18449, 7.01822e-05, -0.0686066]
line: PointStruct [0.847532, -5.80018e-05, 0.0566997]

If we set offTrans in the way:

    vtkSPtrNew( offTrans, vtkTransform );
    offTrans->Concatenate( scaleTrans );
    offTrans->Update();

The result showed that it just enlarge the image on the x-axes direction, but we had rotated the image so it will bring disaster.

line: PointStruct [0.826446, 0, 0]
line: PointStruct [0.826446, 0, 0]
line: PointStruct [1.21, 0, 0]
line: PointStruct [1.21, 0, 0]
line: PointStruct [1.21, 0, 0]

For offTrans,
reduce image: (dynamic matrix, elements in the matrix will change as rotating image)

    \[\begin{pmatrix} 0.836604 & 0 & 0.0407393 & 0\\ 0 & 0.826446 & 0 & 0\\ 0.0407393 & 0 & 0.989843 & 0\\ 0 & 0 & 0 & 1 \end{pmatrix}\]

enlarge image: (dynamic matrix)

    \[\begin{pmatrix} 1.19771 & 0 & -0.0492945 & 0 \\ 0 & 1.21 & 0 & 0 \\ -0.0492945 & 0 & 1.01229 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\]

For single scale transform,
reduce image: (static matrix)

    \[\begin{pmatrix} 0.826446 & 0 & 0 & 0\\ 0 & 0.826446 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end{pmatrix}\]

enlarge image: (static matrix)

    \[\begin{pmatrix} 1.21 & 0 & 0 & 0\\ 0 & 1.21 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end{pmatrix}\]

There are two important common senses for matrix (except a few special situations).

    \[A \times B \neq B \times A\]

    \[A \times B \times A^{-1} \neq B\]

The second inequality is the reason why we need to concatenate image user transform and its inversed transform.

cout << "=========== matrix =========\n";
scaleTrans->PrintSelf( std::cout, vtkIndent() );

vtkSPtrNew( offTrans, vtkTransform );
offTrans->Concatenate( worldTrans );
offTrans->Concatenate( scaleTrans );
offTrans->PrintSelf( std::cout, vtkIndent() );

offTrans->Concatenate( worldInversedTrans );
offTrans->Update();
offTrans->PrintSelf( std::cout, vtkIndent() );
cout << "=========== end =========\n";

Matrix output:

//Original matrix
0.826446 0 0 0 
0 0.826446 0 0 
0 0 1 0 
0 0 0 1 

335.405 0.382796 0.322301 0 
-2.66527 354.24 0.0187427 0 
-114.165 -7.14541 0.946452 0 
0 0 0 1 

//new result matrix
0.844475 0.0010484 0.0529412 0 
0.0010484 0.826507 0.00307868 0 
0.0529412 0.00307868 0.981911 0 
0 0 0 1 
Categories: VTK

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
0
Would love your thoughts, please comment.x
()
x