Я работаю над простой подпрограммой вращения, которая нормализует вращение объектов от 0 до 360 градусов. Мой код C#, кажется, работает, но я не совсем доволен этим. Может ли кто -нибудь улучшить код ниже, делая его немного более надежным? < /P>
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;
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/162 ... -0-and-360