[vtkusers] how to calculate new coordinate after rigibody transformation

Gang GAO g.gao at cs.ucl.ac.uk
Mon Nov 20 11:04:29 EST 2006


I created a sphere whose centre is c(x,y,z). To visualise the sphere, I
created an actor, sphereActor for the sphere. Firstly, I rigidly rotated
the actor by a degree of alpha:

sphereActor->rotateX(alpha);
sphereActor->rotateY(alpha);
sphereActor->rotateZ(alpha);

Secondly, I used a customised transform by:

sphereActor->SetUserTransform(custom_transform);

Now I can visualised the transformed sphere without any problem. The
problem is I don't know how to calculate the coordinate of the
transformed sphere centre. The following codes show what I did:

double *c = sphere->GetCenter();
vtkMatrix4x4 *mat = sphereActor->GetMatrix();
vtkMatrix4x4 *userMat = sphereActor->GetUserMatrix();

double *tmp = mat->MultiplyDoublePoint(centre);
double *t_centre = userMat->MultiplyDoublePoint(tmp);
/////////release memory and so on...

But unfortunately, the t_centre cannot match the position of the
transformed sphere drawn on the screen. Could anyone tell me what is
wrong with my code and how to correct it?

Thank you so so much...





More information about the vtkusers mailing list