Rotate and Translate a gp_Trsf

I see that I can both translate and rotate a gp_Trsf.
Why doesn't this code work:
gp_Vec veclocation(1000, 0, 0);
gp_Trsf trsf;
trsf.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 1.57);
TopLoc_Location toploc_location(trsf);

When I both run trsf.SetTranslation(...) and trsf.SetRotation(...) only the rotation is made. When I uncomment the trsf.SetRotation(...) line the translation works...

How come I can't do both at the same time?

Rob Bachrach's picture

That's just not the way the class is defined. If you read the documentation on gp_Trsf, it says that these functions "change this transformation into..." If you want to set both, try calling SetRotation followed by a call to SetTranslationPart.

d00_ape's picture

Ok. buy now I think I trixed it up like this:
gp_Vec veclocation(locationX, locationY, locationZ);
gp_Trsf trsf;
trsf.SetRotation(gp_Ax1(gp_Pnt(locationX, locationY, locationZ), gp_Dir(0, 0, 1)), angle);
gp_Trsf t;
trsf *=t;
TopLoc_Location toploc_location(trsf);

"If you read the documentation... ... change this transformation into..."
-> I start to think I don't have the complete documentation (I have 5.2) Where did you read that?


You should read comments in the cdl files.

Very often, the comments in cdl files are better than the official documentation.

For example, I never read the documentation about the "gp" package.
The comments in the "gp_Trsf.cdl" file are very easy to understand and will help you to use this class.