RealityKit Transform rotation: choosing clockwise vs. anti-clockwise

I'm using Transform's move(to:relativeTo:duration:timingFunction:) to rotate an Entity around the Y axis in an animated fashion (e.g., duration 2 seconds)

Unfortunately, when I rotate from 6 radians (343.7*) to 6.6 radians (378.2*), the rotation does not continue anti-clockwise past 2 pi (360*) but backwards to 0.317 radians (18.2*).

Is there a way to force a rotation about an axis to go in a clockwise or anti-clockwise direction when animating?
Update:

I checked the Entity's initial rotation rotation (simd_quatf) and destination rotation used in move(to:relativeTo:duration:timingFunction:), and then I checked the Entity's rotation after the animation completes.

The axis Y component after the animation completed has flipped (and so the angle has changed accordingly)

Here is what I get "normally" (or at least how I expected) The Final angle and axis are the same as the destination I gave to the animation function:
Code Block
Initial Angle: 171.89, Vector: < 0.00, 1.00, 0.00>
Destination Angle: 206.26, Vector: < 0.00, 1.00, 0.00>
Final Angle: 206.26, Vector: < 0.00, 1.00, 0.00>


Here is what I get just prior to the unexpected behavior:
Code Block
Initial Angle: 206.26, Vector: < 0.00, 1.00, 0.00>
Destination Angle: 240.64, Vector: < 0.00, 1.00, 0.00>
Final Angle: 119.36, Vector: < 0.00, -1.00, 0.00>


Note the Y component of the axis has flipped and the angle is 119.3 = 360 - 240.64.

I had not counted on the Y axis flipping.

I guess the answer is not to assume the axes (and angle) after the animation completes are the same as the axes (and angle) supplied as the destination Transform in the move(to:relativeTo:duration:timingFunction:) function.


In RealityKit the animation will always take the shortest path to get to the correct transform. This means that rotations will take the shortest distance.

If you want to force the animation to go the other way around you'll have to add two animations in sequence: the first one goes half way round the anticlockwise direction, and the second is the final transform of your entity.



This also means that you can't spin around an axis object continually without doing something similar - which is very annoying!!
RealityKit Transform rotation: choosing clockwise vs. anti-clockwise
 
 
Q