@thomthom said:
In the same way my example took the local 3d position and transformed it with the combined transformation for all the containing groups/components you must apply the combined transformation to your vector of orientation/direction.
Sure thomthom, I get that. My pb is deeper... OK, I have to give the details! Here is what I understood so far:
An object has a 4x4 transformation matrix M attached that combines three parameters defining the geometrical state of the object:
- the position T in space
- the orientation R
- the scale S
Let's say I want to rotate my object (entity is the correct term I think) without changing the position: I will have to
- apply to M the inverse of the translation T (so far I use [0,0,0]-T)
Sketchup.active_model.active_entities.transform_entities(ORIGIN-fromPos,e) #puts the objet at the origin
- then apply the relative orientation dR I need
Sketchup.active_model.active_entities.transform_entities(Geom::Transformation.rotation(ORIGIN,UP,angle),e)
- and finally apply back the translation T.
You may say I should simply use the M.inverse but I think the scale factor would be a probl****em... Or not? (testing around) ... All right. Seems we can simply do :
- apply M.inverse,
Sketchup.active_model.active_entities.transform_entities(e.transformation.inverse,e)
- apply dR
- apply M back
Should be OK.
And here comes my tiny problem: current orientation R of the object is somehow melted with the other parameters T and S in global my transformation matrix M... How the hell do I get a proper orientation R?
Cause I already know the final absolute orientation R' I want my object (or entity, or, in my case, a good old german biplane) to reach: all I need is this initial orientation R to compute the difference dR.
I thought to just get rid of the transformation, discard it and return to the identity and thus apply directly the wanted orientation R', then the position T. But it would be too easy: to fit in a small room, my plane had to be scaled, and I then need to know this scale factor S (that I otherwise simply ignore).
This special line is to thank the reader for the effort he put to read my reply.
And this one is for the people that would give me some clues: I owe you!