Duplicating rotation with axis constraints

Hello.

I need to have one object duplicate the rotation of another, with the following complications:

There is Object A, which may be rotated through various, arbitrary methods, such as animation, physics, etc. There is also Object B, which must imitate Object A’s rotation.

If it was that simple, I could just take Object A’s rotation change and rotate Object B with it. However, Object B may have axis-based limitations: it may, for example, only rotate around the X and Y axes, and only rotate at half a speed around Y. (The axes themselves are constant, for example world axes, or axes of an unmoving parent, so when it comes to these limitations, the axes won’t rotate with the objects.)

The problem is that I can’t break a Quaternion into axis aligned components in order to apply the limitations. I’ve also tried Euler Angles, but the way Unity breaks the Quaternion into Euler Angles seems arbitrary, so just setting eulerAngles.z = 0 will mess things up.

Intuitively, this seems like a simple thing to do, but I can’t figure it out. Can anyone help?

eulers are not so bad 8)
tell us if something bad in this script

Rotater.cs

using UnityEngine;
public class Rotater : MonoBehaviour
{
public Vector3 Limits = Vector3.one * 50f;
public Vector3 Speeds = Vector3.one * 10f;
public Transform targetRotation;
Vector3 myRotation = Vector3.zero;
void Update()
{
Vector3 targetEuler = targetRotation.rotation.eulerAngles;
for (int i = 0; i <= 2; i++)
{
myRotation = Mathf.Clamp(Mathf.MoveTowards(myRotation, Mathf.Repeat(targetEuler + 180f, 360f) - 180f, Time.deltaTime * Speeds), -Limits_, Limits*);*_
_*}*_
_*transform.rotation = Quaternion.Euler(myRotation);*_
_*}*_
_*}
*_