I have a sequence of $n$ points in $\mathbb{R}^3$: $$P_0, P_1, P_2, \ldots, P_n$$ where $ P_i = (x_i, y_i, z_i).$ We can assume, that they are "centered", i.e. the mass center (average) is at (0,0,0).
I want to rotate these points around the center (all at once) so that the point $P_0$ lies on the $z$ axis and the point $P_n$ lies on the $xz$ plane.
For the point $P_0$ I tried computing the points in the spherical coordinate system and substract the $\Theta_0$ to all thetas, $\Theta_i = \Theta_i - \Theta_0$, but this clearly does not work (since $\Theta_i = \Theta_0$ does not mean that $P_i$ should lie on the $z$ axis.) Please help with the rotation.