how to rotate an object relative to another

sorry for english, I use google translator.
how do I rotate object “b” when I rotate object “a” so that it would be child of “a”? the result in the photo at the bottom left (without making the object “b” a child of “a”)

@sailbov, Multiplying Quaternions has the affect of applying one rotation to the other.

I believe this one will do it, but if not try the second example:

  objectB.transform.rotation = objectA.transform.rotation * objectB.transform.rotation; 

The order matters, so the above will not result in the same rotation as:

  objectB.transform.rotation = objectB.transform.rotation * objectA.transform.rotation;