
Tue, 02/07/2006 - 12:18
Forums:
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.SetTranslation(veclocation);
trsf.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 1.57);
TopLoc_Location toploc_location(trsf);
shape.Location(toploc_location);
------------------------------------
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?
Tue, 02/07/2006 - 15:16
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.
Tue, 02/07/2006 - 15:41
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;
t.SetTranslation(veclocation);
trsf *=t;
TopLoc_Location toploc_location(trsf);
shape.Location(toploc_location);
------------------------------------------------
"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?
Wed, 02/08/2006 - 17:17
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.
Regards,
Denis