![Michael Maenz's picture Michael Maenz's picture](https://dev.opencascade.org/sites/default/files/styles/user/public/pictures/picture-9329-1639738431.jpg?itok=4274XSGJ)
Fri, 09/30/2022 - 16:17
Hi,
I don't understand how to make multiple transformations at once and get the result. I'm not sure if it is a problem with the order in which it should happen. The gp_Trsf seems to make one transformation at a time and therefor I think multiple gp_Trsf must be chained to get the result.
My use case is to rotate around a pivot. Therefor I need to subtract, rotate and add to get the correct position.
As per documentation of opencascade (https://dev.opencascade.org/doc/overview/html/occt_user_guides__modeling_data.html#occt_modat_5_1) I need to create a gp_Trsf for every transformation and chain them TopLoc_Location.Multiplied().
This is what I do so far:
gp_XYZ pivot(25., 75., 33.); gp_XYZ originalPos = world.TranslationPart(); //originalPos = (5.0/125.0/20.0) gp_Trsf subTrsf; gp_XYZ subPos = originalPos.Subtracted(pivot); subTrsf.SetTranslation(subPos); TopLoc_Location sub(subTrsf); gp_Trsf rotTrsf; rotTrsf.SetRotation(RA); TopLoc_Location rot(rotTrsf); gp_Trsf addTrsf; addTrsf.SetTranslation(originalPos); TopLoc_Location add(addTrsf); TopLoc_Location result = sub * rot * add;
This is the process in screenshots, the red arrow points to the pivot and the yellow to 0,0,0:
But it does not end in the location where it should be. I also suspect that I didn't understand how the rotation works?
Any help is appreciated...
Thanks!