我有一个关于反向圆周运动的查询.我有下面的代码.壳体1是顺时针圆周运动,壳体2是逆时针方向.情况1和2之间的切换是通过用户触摸完成的.当它从顺时针切换到逆时针它使用相同的值的sin()
和cos()
是timer/1.5
.这导致逆时针运动从我星球上的不同位置开始.我想计算我的计时器所需的值,以便逆时针运动从顺时针运动期间停止的位置开始,从而具有平滑过渡.当我的思绪陷入困境时,有没有人知道正确的数学?
只是对下面代码的一个小解释.我通过获取它所在的行星的x和y坐标来计算我的机器人的位置,并执行一个圆形运动,其半径为行星的半径+ 55(这是我的精灵的舒适高度).
case 1:
positionX = AttachedPlanet.positionX + sin(timer/1.5)*(AttachedPlanet.planetRadius + 55);
positionY = AttachedPlanet.positionY + cos(timer/1.5)*(AttachedPlanet.planetRadius + 55);
timer = timer + 0.02;
break;
case 2:
positionX = AttachedPlanet.positionX + cos(timer/1.5)*(AttachedPlanet.planetRadius + 55);
positionY = AttachedPlanet.positionY + sin(timer/1.5)*(AttachedPlanet.planetRadius + 55);
timer = timer + 0.02;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
670 次 |
最近记录: |