We know the matrix shearing object along a particular axis looks like:

    \[shear_x (dy, dz) =  \begin{pmatrix} 1 & d_y & d_z\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{pmatrix}\]

The shear transform can help us to approve that when a normal vector is transformed using the same matrix that transforms the points on an object, the resulting vector may not be perpendicular to the surface as is shown here for the sheared rectangle. The tangent vector, however, does transform to a vector tangent to the transformed surface.

#include <vtkPointData.h>
#include <vtkSmartPointer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkPolyData.h>
#include <vtkProperty.h>
#include <vtkSphereSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkCommand.h>
#include <vtkSliderWidget.h>
#include <vtkSliderRepresentation.h>
#include <vtkTransform.h>
#include <vtkSliderRepresentation3D.h>
#include <vtkWidgetEventTranslator.h>
#include <vtkWidgetEvent.h>
#include <vtkCubeSource.h>
#include <vtkTransformFilter.h>
#include <vtkAxesActor.h>
#include "./tool.h"

#define vtkSPtr vtkSmartPointer
#define vtkSPtrNew(Var, Type) vtkSPtr<Type> Var = vtkSPtr<Type>::New();

int main(int, char *[])
{
    vtkSPtrNew( source, vtkCubeSource );
    source->Update();

    double elements[16] = { 1, 0, 0, 0,
                            0.5, 1, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1 };
    vtkSPtrNew( trans, vtkTransform );
    trans->SetMatrix( elements );
    trans->Update();

    vtkSPtrNew( transFilter, vtkTransformFilter );
    transFilter-vec_n>SetInputData( source->GetOutput() );
    transFilter->SetTransform( trans );
    transFilter->Update();

    vtkSPtrNew( mapper, vtkPolyDataMapper );
    mapper->SetInputData( transFilter->GetPolyDataOutput() );

    vtkSPtrNew( actor, vtkActor );
    actor->SetMapper( mapper );

    vtkSPtrNew( axes, vtkAxesActor );
    axes->SetTotalLength( 1, 1, 1 ); // change length of three axis

    vtkSPtrNew( renderer, vtkRenderer );
    renderer->AddActor( actor );
    renderer->AddActor( axes );
    renderer->SetBackground( 0, 0, 0 );

    vtkSPtrNew( renderWindow, vtkRenderWindow );
    renderWindow->AddRenderer( renderer );

    vtkSPtrNew( renderWindowInteractor, vtkRenderWindowInteractor );
    renderWindowInteractor->SetRenderWindow( renderWindow );

    renderer->ResetCamera();
    renderWindow->Render();
    renderWindowInteractor->Start();
    return EXIT_SUCCESS;
}

We write a CPlusPlus program to explore the above conclusion.

let’s use matrix to describe the relationship of vector \vec{n} and \vec{t}.

    \[n^T \times t = n^T I t = n^TM^{-1}Mt = 0\]

So the orthogonal vector for Mt is n^TM^{-1}. Let’s name the vector which is perpendicular to all tangent vectors of cell plane n_{N}.

We have:

    \[n_N^T =  n^TM^{-1} \\\]

    \[n_N = (M^{-1})^T n\]

    PointStruct vec_t( 1, 0, 0 );
    trans->TransformVector( vec_t.point, vec_t.point );
    cout << vec_t << endl;

    PointStruct vec_n( 0, 1, 0 );
    trans->Inverse();
    trans->Update();
    vtkSPtrNew( matrix, vtkMatrix4x4 );
    trans->GetTranspose( matrix );
    vtkSPtrNew( MT, vtkTransform );
    MT->SetMatrix( matrix );
    MT->TransformVector( vec_n.point, vec_n.point );
    cout << vec_n << endl;

    cout << vec_n.Dot( vec_t ) << endl;

Output:

PointStruct [1, 0.5, 0]

PointStruct [-0.5, 1, 0]

0
Categories: MathVTK

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