[vtkusers] Re: vtk rotation

Aroosha Laghaee s9738436 at sms.ed.ac.uk
Wed Mar 8 08:45:57 EST 2006


Hi Jess,

If you are using the cube as an individual actor and you want to rotate 
it around the centre of the cube and it's local axis then you need to
specify it's origin (the point around which all rotations happen). So 
you'll need something like the following:

vtkCubeSource* cube = vtkCubeSource::New();
cube->SetCenter(x,y,z);

vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
mapper->SetInput(cube->GetOutput());

vtkActor* actor = vtkActor::New();
actor->SetMapper(mapper);
actor->SetOrigin(cube->GetCenter());

actor->RotateZ(z);

I hope this helps,
               Aroosha

> Hi
>
> I have run into the same problem as yours. Did you ever figure out how to
> rotate a cube around its own axis? If  you did, please send me the code
> showing how to do it.
>
> I am using RotateZ method right now and the cube just rotates around like a
> planet around the solar system. I want it to rotate around its own axis like
> a see-saw.
>
> Thanks.
> Jess
>
>







More information about the vtkusers mailing list