Understanding Rotation in Blender (scales on sphere) I've been following a tutorial https://www.youtube.com/watch?v=Vxc4P0YI2rI which uses Animation Nodes to put scales on a sphere:


So in the beginning one scale is duplicated by the Object instancer and it creates as many scales as there are a vertices on the sphere. In a loop the local  track axis of every scale is rotated according to the vector normales on the sphere (with a Direction to Rotation Node) in order to make them point outwards of the sphere. Below the node setup:


Now I want to rotate the scales on the local z-axis. That's why I added those 3 maths nodes in the Loop frame. I thought if I increase the value for the z-value the scales would rotate accordingly until they are positioned flat on the sphere. But instead they rotate on the local y-axis !
If I increase instead the y-value some of the scales rotate as desired, but others rotate to the opposite direction ! :(


I think I missunderstood the concept of rotating objects in AN / Blender. It would be nice if someone could explain me why I get different results from what I have expected. 
In the video there is a fix shown but the author doesn't explain why he is doing that. The fix is nice (and simple) but without explanation it's worthless since I might encounter similar problems in my own projects when using these techniques.

My blend file can be downloaded here:
https://www.file-upload.net/download-13131607/scalesonsphere.blend.html

Edit:

Hey,
still I've got a problem / something I don't understand. When the initial rotation of the scale I want to put on my Icosphere looks like this:


I get weird results:



However if I rotate my scale like this :



and apply my node tree after (with the Z-axis set as the direction vector in the Direction to Rotation node) everything rotates as expected:



Why do I get different behaviours here?
If you wanted to rotate an object around its z local axis in blender, what do you do? Do you change the rotation z euler value? Or do you use the rotate operator in the local transform orientation? Changing the rotation euler's values rotates the object in its global space, not in its local.

So, how do we rotate in local space in Animation Nodes? The answer is matrix multiplication which is the underlying mathematics behind blender's rotation operators. Compose a translation matrix that include the object's locations, then multiply that by the Rotation Matrix Output of the Direction To Rotation Node, then multiply the result by a rotation matrix, the last matrix act as the local transformation, so by editing its values, you are locally transforming.



Another method would be to use Hamilton product on Quaternions, they are a little harder to understand though. Simply multiply your quaternions by another that include your local rotation information.



Yet another method would be to edit the guide axis to account for your rotation. See the documentation.