[vtkusers] vtkActor->GetPosition(float[3]) returns incorrect value?!

Aroosha Laghaee a.laghaee at sms.ed.ac.uk
Tue Aug 30 09:16:02 EDT 2005


Hello,

I have a vtkActor with its position set at (x,y,z) and origin set at (x',y',z'),
an area outwith the vtkActor geometry. I rotate it using
RotateZ(float) around the origin and would like to know its new position in the
world given this rotation. vtkActor->GetPosition(float[3]) gives me (x,y,z).
But I expect to get (x",y",z"). What am I doing wrong?

#include "vtkCubeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include <conio.h>

int main()
{
	vtkCubeSource *cube = vtkCubeSource::New();
	cube->SetXLength(1);
	cube->SetYLength(1);
	cube->SetZLength(1);

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

	vtkActor *cubeActor = vtkActor::New();
	cubeActor->SetMapper(cubeMapper);
	cubeActor->SetPosition(5,1,0);
	cubeActor->SetOrigin(5,5,0);

	vtkRenderer *ren= vtkRenderer::New();
	ren->AddActor(cubeActor);
	ren->SetBackground(0.1,0.2,0.4);

	vtkRenderWindow *renWin = vtkRenderWindow::New();
	renWin->AddRenderer(ren);
	renWin->SetSize(300,300);

	renWin->Render();

	for(int i=0;i<90;i++){
		cubeActor->RotateZ(1);
		renWin->Render();
	}

	float pos[3];
	cubeActor->GetPosition(pos);
	printf("\nPos is %f,%f,%f",pos[0],pos[1],pos[2]);

        getch();
	return 0;
}

Thanks,
    Aroosha




More information about the vtkusers mailing list