小编Jun*_*per的帖子

标准化0到360之间的方向

我正在研究一个简单的旋转程序,它将物体旋转归一化到0到360度之间.我的C#代码似乎正在运行,但我并不完全满意.任何人都可以改进下面的代码,使它更健壮吗?

public void Rotate(int degrees)
    {
        this.orientation += degrees;

        if (this.orientation < 0)
        {
            while (this.orientation < 0)
            {
                this.orientation += 360;
            }
        }
        else if (this.orientation >= 360)
        {
            while (this.orientation >= 360)
            {
                this.orientation -= 360;
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# angle rotation

21
推荐指数
6
解决办法
4万
查看次数

标签 统计

angle ×1

c# ×1

rotation ×1