# OmniGraph rotate to orientation behaving strangely for minor movements

I have an action graph that rotates an object to look at the camera. I use Rotate to Orientation fed from Get Look At Rotation. As I move around the objects, they turn back towards the camera, but occasionally do a full rotation first. Watching some of the rotation values, they flip from values like180 to -180 for slight movements. It happens multiple times as I move around the target object.

Before movement:

After slight sideways movement of camera (interestingly this one has z of zero):

Another minor movement example, before:

After:

Is there any way to stop this flipping around?

I posted a video on Discord.

Yes I see. Let me see if I can find out for you.

Ok I asked the experts and they knew what it was straight away. We have seen this before. It is where the object gets very very close to “0 degrees” or on a “pure” axis. This is a problem with programming angles in XYZ Euler and not quaternion.

Euler Angles · UnityTipsRedux (gitbooks.io)

Beyond this I cannot help much more.

Thank you for chasing it up. Could you pass a feature request to the core team - add quaternion input support for Rotate To Orientation.

Note: Normally “orientation” is a quaternion (e.g., xformOp:orient is a quaternion, Get Look At Rotation output has Rotate XYZ vector3 and “Orientation” quatd4 – except Rotate to Orientation has an input of Target Orientation that is a vector3).

Zero angles I think will be somewhat common as looking from a flat angle will mean the Z rotation is normally zero (or ±180). E.g., walking around a target and use it to target the camera will frequently be at eye level I think.

Workaround: Set the rotation speed to something much higher than the frame rate - then you don’t notice! ;-)

We already support this I think. You can add a 4 way matrix to any object.

That would be convenient, but unfortunately does not seem to be the case. The docs says its vectord[3] Rotate To Orientation — Omniverse Extensions latest documentation , Action Graph window hover says vectord[3] (screenshot below), and I tried both quaternion and matrix4 - the Action Graph window would not let me connect them. (I tried using nodes like Make Transformation Matrix from TRS to generate a matrixd[4] transform. They won’t connect via the Action Graph window.)

This is one painful thing in OpenUSD - multiple ways to specify a transform makes life harder for tools.

Gimbal lock does not always matter. In this case, because it visually animates from the current orientation to the new orientation, it does matter.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.