Scaling Transformation
-
So apparently applying the following scaling transformation to a Group scales the Group along the world axes, and not the Group's axes. (Shown in wireframe to show Group axes.)
It just seems scaling along the Group's axes would have been the expected result.
tr = Geom;;Transformation.scaling( 2, 1, 1 ) group.transform! tr
So I need to ask, how do I go about getting the Group to scale 2x along its X axis, regardless of its rotation?
In answer to my own question, the only solution I found is to create a new transformation, apply the scaling first, then apply the position and rotation transformations of the original Group. There are other ways to order the transformations, but the scaling must be done before the rotation.
-
Jim, have you looked at my JS_Place3dTexture source? The cpp file here: http://www.pixero.com/files/JS_Place3dTexture.zip
At the bottom of it there's the order for multiplying the matrices to get it right. -
@jim said:
So apparently applying the following scaling transformation to a Group scales the Group along the world axes, and not the Group's axes. (Shown in wireframe to show Group axes.)
It just seems scaling along the Group's axes would have been the expected result.
> tr = Geom;;Transformation.scaling( 2, 1, 1 ) > group.transform! tr >
[attachment=0:r2ix4t33]<!-- ia0 -->Clipboard01.jpg<!-- ia0 -->[/attachment:r2ix4t33]
So I need to ask, how do I go about getting the Group to scale 2x along its X axis, regardless of its rotation?
In answer to my own question, the only solution I found is to create a new transformation, apply the scaling first, then apply the position and rotation transformations of the original Group. There are other ways to order the transformations, but the scaling must be done before the rotation.
Jim,
Multiplying 2 matrices together is non-commutative (unlike with regular numbers). ie A * B is not the same as B * A for matrices.
The transform method does group_matrix * your_matrix , what you want is your_matrix * group_matrix
So just all you need to do is get the group matrix out multiply it with yours and set it back on the group to ensure you get the order you expect.Adam
-
Thanks for the help.
Jan, I haven't looked at your code yet, but I plan to.
Adam, I tried what you said (at least I think I did,) but ultimately, this is what worked for me: (assume a single Group is selected)
m = Sketchup.active_model e = m.active_entities s = m.selection trs = Geom;;Transformation.scaling( 2, 1, 1 ) s[0].transformation *= trs
Which seems counter to what you said?
-
@jim said:
Thanks for the help.
Jan, I haven't looked at your code yet, but I plan to.
Adam, I tried what you said (at least I think I did,) but ultimately, this is what worked for me: (assume a single Group is selected)
> m = Sketchup.active_model > e = m.active_entities > s = m.selection > > trs = Geom;;Transformation.scaling( 2, 1, 1 ) > s[0].transformation *= trs >
Which seems counter to what you said?
It really depends on what the semantics of their * operator is. ie does it pre- or post- concatenate the matrix - but glad you're all sorted either way!
-
Just for reference, the following works for scaling along the Group's axis:
m = Sketchup.active_model e = m.active_entities s = m.selection tr = s[0].transformation trs = Geom;;Transformation.scaling( 2, 1, 1 ) s[0].transformation = (tr * trs)
but this scales along the global axis:
s[0].transformation = (trs * tr)
as does this:
s[0].transform! trs
Advertisement