views:

107

answers:

2

Hello,

I have an object which has a position, a rotation angle and a scale (x and y). The overall transform matrix is as follows :

QTransform xform;
xform.translate(instance.definition.position.x, instance.definition.position.y);
xform.rotateRadians(instance.definition.rotation);
xform.scale(instance.definition.scale.x, instance.definition.scale.y);

I need to scale this object using a global scale which then modifies the local scale of the object. For example, the object is rotated by 45 degrees, I apply a scale of 1,2, I need to know how this affects the local scale as it should affect both local scale axes.

Thanks.

PS : maybe this is impossible due to being a non affine transformation, I don't know, I didn't find much on Google about this particular problem

UPDATE : I think I need to have at least a 3 col by 2 rows matrix transform to keep enough information, I tried some things in SVG which uses this kind of matrix transform and it seems to work, I will need to update this matrix according to the position and rotation though.

A: 

Either scale the object first

or calculate the inverse matrix, apply it to object (that undoes the translation/rotation), scale it and apply the first matrix again.

Aaron Digulla
The object is scaled first in the code above.
speps
From the code, it looks as if it's translated first.
Aaron Digulla
A: 

If you take, say, a rectangle, rotate it so that its edges are no longer parallel to the coordinate axes, then apply a scaling factor to, say, X, it will no longer be a rectangle. It will be a parallelogram, and your data structures will have to accommodate more information than they do now.

Beta
They use scaleX and scaleY in ActionScript too, also applied prior to the rotation so I thought this wouldn't a problem.So there is no way to compute my local scale from this parallelogram?
speps
How are you defining local scale? Do you want to calculate what the edge lengths were before the application of the global scaling?
Beta
local scale is scaling relative to the center of the object, for example (or a point that is "close" to the object, say a corner).
Aaron Digulla
The local scale is just factors for each X and Y applied as if there are no rotation. The order of transformation is scale > rotation > translation. I updated the question.
speps