3D relative angle sum calculation

c#, euler-angles, math, unity-game-engine

Solution

One possible solution I found:

        (r2 * Quaternion.Inverse(r1)).eulerAngles.Y

Problem

I have a 3D object with rotation r1 in a quaternion form. I rotate it with local euler angles: ``` transform.Rotate(new Vector3(0f, 15f, 0f), relativeTo: Space.Self); // right transform.Rotate(new Vector3(-10f, -5f, 0f), relativeTo: Space.Self); // left up transform.Rotate(new Vector3(0f, 0f, 90f), relativeTo: Space.Self); // 90 clockwise ``` Now I have rotation r2. How can I retrieve the local Y rotation sum 15-5+0=10 if I don't know what angles have been applied? It may be impossible to get exactly that value (10) but you've got my idea. May be I can just get Y diff in the local r2 space?

Original source