[vtkusers] vtkTransformation one prop following another

Jose Ignacio Prieto joseignacio.prieto at gmail.com
Thu Nov 28 14:04:54 EST 2013


Hi all,

I am preparing a ruler widget that will measure props3d. Now I would like
the ruler to follow the prop if the prop is applied a vtkTransform T.
T comes from:

        t = vtkTransform::New();

        t->SetMatrix(picker->GetProp3D()->GetMatrix());

        t->PostMultiply();

        t->Translate(-cellC[0], -cellC[1], -cellC[2]);

        t->Concatenate(rotMtx);

        t->Translate(cellC[0], cellC[1], cellC[2]);

        t->Translate(deltaVector[0], deltaVector[1], deltaVector[2]);


Then what I was trying is to apply the same transform T to the ruler
through an callback, every time the prop is moved. The problem is that
if the prop was already transformed before placing the ruler, then the
ruler is transformed with T as the whole prop transform from the
beginning instead of just the "last" transform that was applied to the
prop.

So my solution was to copy T the first time the ruler is set, and then
whenever a transformation is applied to the prop, I would cancel the
former transformations by post - multiplying the inverse of the copy
of T I made when setting the ruler. The code looks like this

    inverseOriginal = vtkTransform::New();

    localMatrix = vtkTransform::New();

    inverseOriginal->DeepCopy(rep->GetInitialTransformMatrix());

    localMatrix->DeepCopy(matrix); // where matrix is the current T transform

    inverseOriginal->Inverse();

    inverseOriginal->Update();

    localMatrix->Concatenate(inverseOriginal);

    localMatrix->PostMultiply();

    localMatrix->Update();

    WidgetRep->UpdateMatrix(localMatrix);


The problem is that the results are the opposite. When I move it
upwards, the ruler moves down and viceversa. The rotations are handled
ok.


What could be the mistake??


Thank you very much


Ignacio Prieto



-- 
José Ignacio Prieto
Software Engineer
Biomedical Imaging Center
Pontificia Universidad Catolica de Chile
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131128/d422a0d3/attachment.htm>


More information about the vtkusers mailing list