I need to rotate an object along arbitrary axis (local Z) in the range of 360 degrees. However, the rotate_axis method limits the angle value to 180 degrees and adds a sign (+/-) to allow for 360 degrees rotation. So if I need to animate a rotation of an object by more than 180 degrees it behaves in an undesired way (Animation 1).
This is the code from first animation: obj.rotation_euler.rotate_axis("Z", radians(40))
The second animation was made with manual input into rotation Z field.
What I'd like to achieve is shown in the second animation. I know it is sometimes difficult to come up with a solution without knowledge of what the end product should look like. The final effect is a cube that follows an animated path combined of multiple keyframes on a sphere. Like a car driving on the surface of the earth. (see below animations)
What I need to do is to rotate a cube (first picture below) so that its' local Z axis is aligned with a sphere normal (blue side up - second picture below), and its' local X axis is aligned with a line joining two visible plain axes (red side facing one of plains - third picture below). Now at the end ot this operations I need to have a 360 degrees data instead of +/-180 in order to avoid overrotation as shown in the first animation above.
Take a look at the animation at the end.
Here you can see what I am dealing with. When rotation around Z skips the 180 the cube is overrotating.