Value of Transformation changes when rotation or scaling is applied.

Case 1:
When I move the the component in X by 500 and Y by 500 , then the transformation (local transformation) is given by API is
X=500 Y=500 Z=0.00 (Refer image 1)

Case 2:
Now I am applying the rotation to X axis and Y axis by 50 each then the values of transformation is as follow
: X: -281.79 Y=444.789 Z=393.49 (Refer image 2)

Case 3:
Now I am applying scale of 2 to the component then values of transformation is as follow
X=263.602 Y=-151.904 Z=566.1063 (Refer image 3)

original location is : 263.602 , 151.904, 566

Questions:
1] How can the actual rotation values for each axis be calculated from the transformation?
2] Why do the X, Y, and Z values change when rotation and scaling are applied to the shape?

Thanks in advance for your help.

Extras:
I tried to calculate angle using
[cpp]
gp_Quaternion q = m_tempRecordedTransfomration[active_hashcode].GetRotation();
double aProbe, bProbe, cProbe;
q.GetEulerAngles(gp_Intrinsic_XYZ, aProbe, bProbe, cProbe);
[/cpp]

Dmitrii Pasukhin's picture

Hello, could you share how you update location? SetTransformationPart do not update rotation or some other separeted "Part" methods.

Best regards, Dmitrii.

rahulmulik9's picture

This are result before any transformation
CurrentObject->LocalTransformation().TranslationPart() => give me x=0,y=0 z=0

for rotation around x axis :
gp_Trsf x;
gp_Trsf transformation= CurrentObject->LocalTransformation();
double angle = (45 * PI) / 180;
gp_Ax1 ax(p1, gp_Dir(1, 0, 0)); //p1 is location of component
x.SetRotation(ax, angle);
x.Multiply(transformation);
CurrentObject->SetLocalTransformation(x);

CurrentObject->LocalTransformation().TranslationPart() => give me x=0,y=441.33 z=56.41

for scaling :
gp_Trsf scaleTransform;
scaleTransform.SetScale(p1, scalefactor); //scale factor 1.5
scaleTransform.Multiply(transformation);
CurrentObject->LocalTransformation().TranslationPart() => give me x=132.33 ,y=76.84 z=2846.24

My question is why this values changes when we apply rotation or scaling ?

gkv311 n's picture

This is because matrix multiplication order is important. If you want to rotate object first and then translate it - you need multiply transformations in different order or specify different center of rotation.

Articles, that might be helpful: World-View-Projection matrix, Transformations in OCCT

Order

rahulmulik9's picture

I'm not moving the component anywhere, but still, when I apply rotation or scaling to the component by using manual value or using manipulator axis,
the translation values (X, Y, Z) of the transformations (LocalTransformation().TranslationPart()) change.
Any reason for that?