I'm simply trying to find the global rotation of a bone in pose mode using python
i.e. what angle a bone makes with the global axis?
The closest I've come is:
for pb in context.selected_pose_bones_from_active_object:
pb_world_matrix=armature.matrix_world @ pb.matrix
loc, rot, scale = pb_world_matrix.decompose()
rot= rot.to_euler();
print(pb.name,"x=",math.degrees(rot.x),"y=",math.degrees(rot.y),"z=",math.degrees(rot.z))
Edit:
let me explain what I mean with an example:
As you can see in the gif above, initially the angles are:
x_glob= 0deg
y_glob= 0deg
z_glob= 0deg
then I first rotate it by 38deg
on global y orientation then I rotate by 41.3deg
on global x orientation so the final output should be:
x_glob= 41.3deg
y_glob= 38deg
z_glob= 0deg
I think a better way of looking at the problem is finding the angle made with the planes of global axis (I couldn't find the wording to phrase it till now)