The center of mass of the points can be computed with vtkCenterOfMass. But if you need the center of mass of the enclosed volume, I don’t think VTK provides any methods for that.
The bounds of the actor are computed by rotating the bounds of the data and then computing a new bounding box with respect to world coordinates. My feeling is that it should give the same result, but I would have to examine the code and go through the math to be certain.
However, please note that GetCenter() is only meant to be a quick-and-dirty method to get the center of the dataset. That’s why it just uses the bounding box instead of doing a more sophisticated computation.
In fact, I find the actor.SetUserMatrix() is different from newPoly=vtkTransformPolyDataFilter.GetOutput(); actor2=generateActor(newPoly). In order to debug this problem, I compute the center.
I rethink about this process. I think the bounds of the actor may be not equal to the bounds of rotated polydata.
Please have a look at the above figure. Suppose we have four points (black point), and it formed a square with 1 length of side.
Firstly, the red line indicates the coordinate system. In this situation, the length of bounds side should be \sqrt 2.
Then, the matrix rotate the first coordiante system (red line) to the second coordinate system (gren line). After the rotation, the bounds of the data is rotated, and the rotated bounds should has \sqrt 2 length of side, because rotation do not change the length. To calculate the new bounding box, the bounds length should be larger than \sqrt 2.
However, for the rotated poly data, the bounds length should be 1.
In a word, to calculate the bounds of actor, directly rotating the bounds should be an inaccurate method.
But since the bounds are rectangular, the center should stay the same.
The main idea, though, is that GetCenter() is only meant to give an approximate result. That is why I recommend using a center-of-mass to test vtkTransformPolyDataFilter.
If you want to test the matrix of the actor, you cannot do this by computing the center of the data. This is because the transformation of the actor occurs on the GPU via OpenGL. To test the matrix of the actor, the best method is to render two actors and visually compare the results:
for the first actor, use the actor’s matrix for the transformation
for the second actor, use vtkTransformPolyDataFilter for the transformation
Use actor.GetProperty().SetRepresentationToWireframe() to make it easier to compare the results, and use a different color for each actor. In this way, you should be able to convince yourself that the transformation is accurate.