Quaternion Orientation to XYZ rotation values

I’m trying to use my phone’s orientation sensors to manipulate SOP geometry. Unfortunately, I’m not sure how to parse quaternion data into usable X,Y,Z Euler rotations. As you can see from the below gif, my rotations are fluctuating wildly.
Phone Orientation with Angle CHOP

I’m using ZIG SIM on a Google Pixel 4 XL and importing the X, Y, Z, W quaternions into TD using the OSC In CHOP. From there, I’m feeding the XYZW channels into the Angle CHOP with input set to Quaternion and output set to degrees.

It looks like it’s working but as you can see there’s odd snapping about the axis and the motion of my phone doesn’t really correspond to the output of the Angle CHOP.

Below is my file! Would love some help understanding what CHOPs would be better to parse quaternions.

Phone Orientation.2.toe (6.0 KB)


Notice the rotate order is Rz Ry Rx in that node. Is that the same you have it set to for the node consuming the rotations?

My first instinct was to change the output order thinking that might solve some of my problems but the snapping and locking issue persists.

just wanted to follow up in case you had a chance to look through the attached toe file.
I’m still struggling with this quaternion to euler angle rotation problem.

thanks very much!

Sorry, just looked. I don’t think you can Filter Euler values directly like that, you’ll get all kinds of strange behavior. What you want to do is use a Attribute CHOP to group your rx/ry/rz Eular values into a ‘Quaternion Group’. Then you can use the Lag CHOP with ‘Quaternion Rotation’ mode to lag those. Does that help?

1 Like

Hi Malcolm,

Thanks for the response.
I’m afraid I still don’t understand which values to make into a ‘Quaternion Group’ and how to parse them in the lag CHOP.
I’m sure this can be frustrating to troubleshoot without the exact inputs I’m working with so in the below TOE file, I’ve used the record CHOP with a timer and lookup to replay 10 seconds of my phone’s quaternion channels imported via OSC.

Phone Orientation_recorded input.toe (17.1 KB)

Please let me know how I should rework this network to manipulate my geometry transformations.

Thanks so much!

Sorry for the delay in answering. The first step is to rename the channels into qx, qy, qz, qw and then put that into a Transform CHOP to convert it to Euler angles. Then you can use an attribute CHOP to group the rx ry rz into a quaternion group, which the lag can work with.
The key thing is that TD doesn’t pass or know about quaternions except for a few nodes to convert in and out of them (like the Transform CHOP). Other nodes that work using Quaternion math behind the scenes, but their input and output are stored as Euler angles


Any luck with the project?
I am trying to achieve the same concept of tracking the rotation of a plane with the inputs from ZigSim OSC.

I am looking for live phone orientation so I can change the geometry accordingly (mimicking the phone angles- " position" in the render)

Can you share the progress, because i am stuck too :slight_smile: