@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离中间圆偏好多啊。
Image may be NSFW.
Clik here to view.
帖子: 1
参与者: 1