Just had a bit of a Eureka moment while having a cigarette in the garden.
Every problem I set out in my previous post vanishes when you look at the world from Phoebe’s point of view rather than the Earth’s.
The code currently tries to hang onto the Earth frame as long as it can, leading to what were starting to look like insurmountable problems.
But if I rework the code into Phoebe’s frame, all those problems vanish in a puff of smoke.
All that’s required is to take the horizontal and vertical PID targets and matrixify them into Phoebe’s frame and I have the right matrix to do that, and then everything else just drops out. I need to get coding!