先旋转再平移还是先平移再旋转?它有什么区别?
我在 HTML5 中开发的代码中有这两行:
context.rotate(radian);
radian += 0.1;
context.translate(128,128);
上面的结果给出了与下面的行不同的结果:
context.translate(128,128);
context.rotate(radian);
radian += 0.1;
这 2 个代码片段之间有什么区别?我得到不同的结果,但计算为何以及如何不同,我无法理解这一点。
I have these two lines in my code being developed in HTML5:
context.rotate(radian);
radian += 0.1;
context.translate(128,128);
The above result gives a different result the below lines:
context.translate(128,128);
context.rotate(radian);
radian += 0.1;
What is the difference between these 2 snippets of code? I get different result but why and how calculation differs, I am not able to understand this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
差异是转变的根源。如果您之前执行过平移变换,也许您必须调整以下旋转变换的变换原点,反之亦然。这取决于您想要实现的结果。
The difference is the origin of the transformation. If you perform a translate transform before, perhaps you have to adjust the transform-origin of the following rotate transform, or viceversa. It depends on the results you are trying to achieve.