[vtkusers] Rotating a vtk actor using world coordinates
David Gobbi
david.gobbi at gmail.com
Tue Sep 29 11:25:36 EDT 2015
Hi Chiranjib,
The actor's Rotate methods are inherited from vtkProp3D, but the code that
you
show is from vtkTransform.
The actor's RotateWXYZ method commutes the matrices (i.e. multiplies them in
a different order) as compared to the RotateX,Y,Z methods. The original
author
might have had a reason for doing this, but I doubt it was a good enough
reason
to justify the confusion that this method causes...
You can use SetUserMatrix as follows:
actor->SetUserMatrix(transform->GetMatrix());
- David
On Tue, Sep 29, 2015 at 4:46 AM, Chiranjib Sur <sur.chiranjib at gmail.com>
wrote:
> Hi,
> The implementation of the rotation transform are as follows (from
> vtkTransform.h file : URL
> https://github.com/Kitware/VTK/blob/master/Common/Transforms/vtkTransform.h
> )
>
> void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }; void
> RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }; void RotateZ(
> double angle) { this->RotateWXYZ(angle, 0, 0, 1); }; Therefore, how there
> going to be a difference between
>
> actor->RotateX(45);
> actor->RotateY(45);
>
> and
>
> actor->RotateWXYZ(45, 1, 0, 0);
> actor->RotateWXYZ(45, 0, 1, 0);
>
> Can anyone please explain this a bit? David, Is there any example of the
> SetUserMatrix() available to learn about it?
>
> Thanks,
> Chiranjib
>
> On Mon, Aug 10, 2015 at 10:38 PM, David Gobbi <david.gobbi at gmail.com>
> wrote:
>
>> Hi Drak,
>>
>> Generally it's better design to build a transform or matrix and then
>> apply that to the actor via SetUserTransform() or SetUserMatrix(). That
>> way, the transform or matrix is available to you if you have to move other
>> points or actors between coordinate systems.
>>
>> To rotate around a point in space, you have to apply a translation to put
>> that point at the origin, then do the rotation, and then translate back
>> again.
>>
>> - David
>>
>> On Mon, Aug 10, 2015 at 10:53 AM, Drak <draktharrblorf at gmail.com> wrote:
>>
>>> I should add that I'm using the vtkImageActor with a vtkImageData as a
>>> source. It seems that my point of rotation is the bottom left of my image
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150929/4a2e0357/attachment.html>
More information about the vtkusers
mailing list