We can use vtkTransform’s function concatenate to do matrix multiplication.
There are three matrix which have the mathematical relationship.

    \[C = A \times B\]

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;
}

Categories: VTK

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Content Summary
: Input your strings, the tool can get a brief summary of the content for you.

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