Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 90503

圆周运动效果不精确

$
0
0

@1351239979 写道:

Vec2& CirclingMotionBy::getPosByAngle(const Vec2& targetPos, float angleBy, Vec2 circleCenter)
{
float xLong;
targetPos.x > circleCenter.x ? xLong = targetPos.x - circleCenter.x : xLong = circleCenter.x - targetPos.x;
float yLong;
targetPos.y > circleCenter.y ? yLong = targetPos.y - circleCenter.y : yLong = circleCenter.y - targetPos.y;
double radius = sqrt(xLong*xLong+yLong*yLong);
double startRadian = atan2f(targetPos.x - circleCenter.x, targetPos.y - circleCenter.y);
double radian = startRadian + CC_DEGREES_TO_RADIANS(angleBy);
double x = radius * sin(radian);
double y = radius * cos(radian);
Vec2 newPos = Vec2(x+circleCenter.x, y+circleCenter.y);
return newPos;
}
旋转角度越靠近180度坐标偏差越大,不知哪里计算错误,还请指教:A圆是旋转0,B是72,C是72+72......CD离中间圆偏好多啊。

帖子: 1

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 90503

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>