Let $\vec Y=\vec X\times\vec P$ and then $\vec {X'}=\cos\theta\cdot \vec X+\sin\theta\cdot \vec Y$. This gives the correct result for an original 90° angle, but for error correction, you may want to normalize $\vec{X'}$ (i.e., divide it by its length); this gives you an approximate result that is closer to 90° if the original angle was off.