【发布时间】:2020-11-11 08:08:18
【问题描述】:
我目前正在使用 Atan2 来计算玩家的航向角。
但是经过一些尝试和错误后,我发现游戏中的角度与“正常”布局的角度有很大不同:
ReturnedAngle = Math.Atan2(Y2 - Y1, X2 - X1); /// ArcTan2 the difference in our Y axis is always passed first followed by X
ReturnedAngle = (180 / Math.PI) * ReturnedAngle; /// Converting our radians to Degrees the convervion ends at 358 not the full 360 degrees.
ReturnedAngle = Math.Round(ReturnedAngle + 360, MidpointRounding.AwayFromZero) % 360; /// MOD and round our angle.
上面是我用来计算航向角的 C# 代码。我的问题是如何将这个角度从“正常”角度系统转换为游戏中的角度系统。
【问题讨论】:
-
能否在左图显示 Y 轴和 X 轴方向?点 (100,100) 和 (100, -100) 在哪里?