I have attache two images with the desired start and end positions.
The Brown Circle is the target rotation. The Orange Square is the parent (the black dot is the pivot point) and the Blue Rounded Square is the child.
How would I calculate the rotation of the parent to align the child to the target rotation?
Well, that’s actually quite easy. You can simply calculate the “difference” between the orientation of your child and the orientation of your target and apply that difference to your parent. It’s as simple as that, at least in theory
In practise there are several things that need to be right for this to work. As you may know (unit) quaternions are generally used to represent relative rotations as well as orientations. Quaternions are somewhat the 3d equivalence to complex numbers in 2d. When you multiply quaternions together, you add their angles together. Though unlike in 2d, in 3d the order in which rotations are applied matters. That’s why quaternion multiplication is not commutative and ofteh the source for all sorts of issues.
While multiplying quaternions does add their angles, dividing quaternions will subtract their angles. Since we only have to deal with unit quaternions (quaternions that have a magnitude of 1), the division is as simply as multiplying one quaternion by the complex conjugate / inverse of the other. You should get the rotation that rotates you from A to B by doing
Quaternion dif = Quaternion.Inverse(A) * B;
As I said, the order may be the other way round. Now you can rotate the parent by this difference. Here again, the order may be the other way round
parent.rotation = dif * parent.rotation;