Hi,
Not sure how to bite following problem, neither know, how to search for the specific answer, while trying to get my head round.
Prior to explaining the case, I just would like to state, I am ok generally with quaternions, identity, vectors, etc. math, when required. But yet struggling this time, to picture the solution.
Lets start simple case scenario (OK).
Imagine docking of the spacecraft, to the spinning orbital space station, around own (forward z) axis.
Normally and easiest way to dock, is to align spacecraft, parallel to axis of the rotating space station.
Then it is simple, to apply spacecraft rotation, to match rotation of space station. And docking can be complete, with no issue.
But what I am trying to achieve, is the camera with look at space station, which spins (rolls) the same, as the docking space station. Result would be simple as that, if I look from behind of spacecraft at space station, spacecraft and stars will appear rotating while docking station will be appearing none rotating (static).
Ok. That is simple to do. By grabbing rotation of the space station and applying roll to the camera. Alternatively getting relative rotation of the docking space station to the spacecraft, along given axis, to get relevant rotation angle.
Now troubling case scenario (Problem).
Imagine same spacecraft and spinning docking space station.
However, this time my spacecraft is approaching the space station from the distance and is not aligned in parallel, to the spinning axis of the docking station. It means, there is some angular offset from the spinning axis, between spacecraft and the station.
For simplicity lets assume, docking station rotates along world forward axis (z).
Then my spacecraft is approaching space station, on the world xz plane, while world position y (up) is 0 (for simplicity), in respect to space station.
Lets see 3 cases:

If my spacecraft would approach space station from z axis (from the front of space station), while x axis is 0, which is 0 degree offset (along world y axis) to forward z axis, looking camera at the station (from the front of station), should rotate (roll), as per described simple case scenario.

If my spacecraft would approach space station from x axis (left / right), while z axis is 0, which is ±90 degree offset (along world y axis) to forward z axis, looking camera at the station (from the side of station), should not rotate (roll).

However, if my spacecraft would approach space station from z axis 1, while x axis is also 1, which is 45 degrees offset (along world y axis) to forward z axis, my look at space station camera rotation should be what? This is a point I struggle atm.
My thoughts to the problem are (your comments are welcome):
 That I should have a vector between spacecraft and space station (straight forward).
 Getting perpendicular to that vector local up (y’) and right (x’) vectors.
 Get a plane of that vectors y’x’, with the world xyz origin of the space station position. In other words, plane is perpendicular to the vector, described in point 1.
 Get space station local right (x) [or up (y)] axis, which are perpendicular to spinning forward z axis.
 Project that x [or y] axis on y’x’ plane ( derived earlier from the vector ).
 Get position of projected vector on the y’x’ plane
 Calculate the angle using atan2 method.
 Apply angle to the roll of to the camera, with look at the space station.
I can see potential problem, when angle offset is approaching absolute ±90 degrees. But I think, I can simply trigger bool flag, to on / off, if angle is too big.
I will get hands on, to try this approach, as soon, as I get chance.
Providing you understood what I had on mind ( without visualization atm.), do you think this approach will work? Or do you know any different (better/simpler?) method (s)?
Many thanks in advance for a contribution.