围绕另一点旋转点的数学函数是:
double new_x = current_x * Math.cos(angle) - current_y * Math.sin(angle);
double new_y = current_x * Math.sin(angle) + current_y * Math.cos(angle);
Run Code Online (Sandbox Code Playgroud)
如果你的中心不在(0,0),你应该先用当前值减去它,然后在最后再添加它们,如下所示:
double new_x = (current_x-center_x) * Math.cos(angle) - (current_y-center_y) * Math.sin(angle) + center_x;
double new_y = (current_x-center_x) * Math.sin(angle) + (current_y-center_y) * Math.cos(angle) + center_y;
Run Code Online (Sandbox Code Playgroud)
请注意,您的角度应该是弧度而不是度数,这样的简单转换就像这样:
double angle = Math.toRadians(degrees);
Run Code Online (Sandbox Code Playgroud)
希望这有帮助!