[vtkusers] vtkTransformation one prop following another

David Gobbi david.gobbi at gmail.com
Thu Nov 28 14:40:41 EST 2013


The only strange thing that I see in your code is this:

  localMatrix->Concatenate(inverseOriginal);
  localMatrix->PostMultiply();

For PostMultiply() to change the order of the concatenation,
it must be called before Concatenate(), not after.

Try doing this instead:

  localMatrix->PostMultiply();
  localMatrix->Concatenate(inverseOriginal);

David




On Thu, Nov 28, 2013 at 12:04 PM, Jose Ignacio Prieto
<joseignacio.prieto at gmail.com> wrote:
> 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
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>


More information about the vtkusers mailing list