如何将椭圆动画路径旋转一定的角度? [英] How can rotate an elliptical animation path by a certain amount of degrees?
本文介绍了如何将椭圆动画路径旋转一定的角度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<$ c我使用以下命令获取实体的x和y位置,因为它随着时间的推移沿着椭圆路径行进: $ c> x = Math.cos(time)* width / 2
y = Math.sin(time)* height / 2
是否有一种简单的方法将整个事物旋转一定的度数,例如45或132?
解决方案
您可以使用简单的旋转转换:
x1 = x * cos(a) - y * sin(a)
y1 = x * sin(a)+ y * cos(a)
其中 a
- 是要旋转的角度。 维基百科文章详细解释了这一点
I'm using the following to get the x and y position of an entity as it travels along an elliptical path over time:
x = Math.cos(time)*width/2
y = Math.sin(time)*height/2
Is there a simple way to rotate the entire thing by a certain amount of degrees, say 45, or 132 for example?
解决方案
You may use a simple rotation transformation:
x1 = x*cos(a) - y*sin(a)
y1 = x*sin(a) + y*cos(a)
Where a
- is the angle to rotate.
This Wikipedia article explains that in detail
这篇关于如何将椭圆动画路径旋转一定的角度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文