我正在研究一个简单的旋转程序,它将物体旋转归一化到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)