使用局部缩放和旋转来缩放对象
我有一个具有位置、旋转角度和比例(x 和 y)的对象。整体变换矩阵如下:
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);
我需要使用全局比例来缩放该对象,然后修改该对象的局部比例。例如,对象旋转 45 度,我应用 1,2 的比例,我需要知道这如何影响局部比例,因为它应该影响两个局部比例轴。
谢谢。
PS:也许这是不可能的,因为是非仿射变换,我不知道,我在谷歌上没有找到太多关于这个特定问题的
信息更新:我想我至少需要有一个3列乘2行的矩阵变换为了保留足够的信息,我在 SVG 中尝试了一些使用这种矩阵变换的东西,它似乎有效,但我需要根据位置和旋转来更新这个矩阵。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先缩放对象
或计算逆矩阵,将其应用于对象(撤消平移/旋转),缩放并再次应用第一个矩阵。
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.
例如,如果您选择一个矩形,旋转它,使其边缘不再平行于坐标轴,然后对 X 等应用缩放因子,它将不再是矩形。它将是一个平行四边形,您的数据结构将必须容纳比现在更多的信息。
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.