# Differnce between many small rotations and 1 large rotation.

I am rotating an object through 180 degrees along a diagonal-
trans = Vector3(1,0,1).normalized
when I do it in one step
transform.Rotate(trans * 180,Space.World)
I get a different answer than if I do it in many small (1 degree steps)
transform.Rotate(trans * 1,Space.World)
executed in a loop 180 times.

in one step I get euler angles (52.7,180,307.3)
in many steps I get (0.4,90,180.4) (little rounding erros I guess)
(0,90,180) is what I expected.

I don’t have a good grasp or Quaternion so I don’t understand what is happening. Can anyone explain to me why I get a different answer when I rotate in a large step. This only happens in my tests when the rotations vector has more than one non-zero value and I normalize it.

below is code I attached to a capsule to test including rotating the capsule and printing the results to the console.

``````import UnityEngine

class Test_function (MonoBehaviour):

def OnMouseDown ():
trans =Vector3(1,0,1).normalized
angle = 180
progress = 0
temp = transform.rotation
transform.Rotate(trans * angle,Space.World)
finalRotation = transform.rotation
Debug.Log("fre:\${transform.eulerAngles}")
transform.rotation =temp
while  (progress <angle ) :
tDelta = 5
transform.Rotate(trans * tDelta,Space.World)
progress += tDelta
//transform.rotation = finalRotation
Debug.Log("prog:\${progress}")
Debug.Log("fr::\${finalRotation}")
Debug.Log("ar:\${transform.rotation}")
Debug.Log("are:\${transform.eulerAngles}")
``````

cheers,
Grant

When you use

``````Transform.Rotate (Vector3, Space);
``````

you are specifying euler angles. To rotate around an axis you should use

``````Transform.Rotate (Vector3, float, Space)
``````

so, don’t multiply but separate with a comma.

``````transform.Rotate(trans, angle, Space.World)
``````

Thank you very much (it was driving me nuts).

I rereading the Doc I see it does explain that

cheers,
Grant

It happens

ORG