Vtktransform * form = vtktransform: New ();
Form-> identity (); // unitization
Form-> rotatez (45 );
Sphere1-> addposition (3.0, 0.0, 0.0 );
Form-> rotatez (45 );
Sphere1-> setusertransform (form );
AboveCodeRotate for 45 degrees consecutively. Each rotation is performed along the model coordinate system, and the function for adjusting the position takes effect.
The reason is that rotatez (45) generates a matrix of 45 degrees of Rotation along the Z axis. This matrix indicates a matrix with the origin as the center and (0, 0, 1) as the axis.
The translation matrix generated by addposition () does not affect the rotation matrix. Therefore, the position of the addposition () function is irrelevant to the final result.
That is, the above Code is equivalent to the following
Vtktransform * form = vtktransform: New ();
Form-> identity (); // unitization
Form-> rotatez (45 );
Form-> rotatez (45 );
Sphere1-> addposition (3.0, 0.0, 0.0 );
Sphere1-> setusertransform (form );