Oops! Sorry, I was in between calls and didn’t notice.
Here’s the code that gives you the angle in degrees, it works on lists as well:
import sys
import clr
import math
clr.AddReference('System.Numerics')
from System.Numerics import *
def euler_from_quaternion(x, y, z, w):
t0 = +2.0 * (w * x + y * z)
t1 = +1.0 - 2.0 * (x * x + y * y)
roll_x = math.atan2(t0, t1)
t2 = +2.0 * (w * y - z * x)
t2 = +1.0 if t2 > +1.0 else t2
t2 = -1.0 if t2 < -1.0 else t2
pitch_y = math.asin(t2)
t3 = +2.0 * (w * z + x * y)
t4 = +1.0 - 2.0 * (y * y + z * z)
yaw_z = math.atan2(t3, t4)
return roll_x, pitch_y, yaw_z # in radians
#iterate list of transforms
transforms = IN[0]
angles = []
for v in transforms:
matrix = Matrix4x4(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15])
decomposed = Matrix4x4.Decompose(matrix)
rotation = decomposed[2]
euler = euler_from_quaternion(rotation.X, rotation.Y, rotation.Z, rotation.W)
angles.append(math.degrees(euler[2]))
OUT = angles
I took the freedom to try with your streamId, it works but will just need some rounding:
P.S.
We’ll look into those weird ellipses being displayed!