Consider an arbitrary state: $$|\psi\rangle = a|0\rangle+b|1\rangle,$$
where $a=\cos\left(\frac{\theta}{2}\right), b=\sin\left(\frac{\theta}{2}\right)e^{i\phi}$ (neglecting global phase), $\phi$ is the polar angle, $\theta$ is the azimutal angle on the Bloch sphere.
The Bloch sphere vectors can be found as: $$r_z=\cos\left(\theta\right)\,,$$ $$r_x=\sin\left(\theta\right)\cos\left(\phi\right)\,,$$ $$r_y=\sin\left(\theta\right)\sin\left(\phi\right)\,.$$
If I want to project this state $|\psi\rangle$ into the state $|1\rangle\langle1|$, I can get $p_z$ component of the Bloch vector:
$$p_z = |\langle1|\psi\rangle|^2 = |\langle1|\left(a|0\rangle+b|1\rangle\right)|^2 = |b|^2 = \sin^2\left(\frac{\theta}{2}\right) = \frac{1-\cos(\theta)}{2} = \frac{1-r_z}{2}$$
I know, that to get $p_x$ and $p_y$ components, I need to rotate the Bloch vector before the measurement (projection into the state $|1\rangle\langle1|$) around $x$ or $y$ axis (depending on the projection) by $\frac{\pi}{2}$, but I have no idea how to derive these components mathematically as for $p_z$