3D rotation about z-axis I am struggling to understand the 3D rotation.

I have one picture from internet which is drawn by me.
The initial object position is $A(x_1, y_1, z_1).$ We need rotate it into $A'(x_2,y_2,z_2)$ about $z$-axis by angle $\angle A'PA=\theta.$
And we take $P$ be the any point in $z$-axis. It makes $\angle APS=\phi.$
Now we find $cos \phi= \frac{PS}{AP}=\frac{x_1}{r}\Rightarrow x_1=rcos \phi.$ But we know $OQ =x_1$ but here slides take $PS =x_1$ and they forcefully match the answer which is wrong.
My question is  $PS =x_1$ or $OQ =x_1?$
 A: 
Given the point $A$ you shall imagine to draw a parallelepiped with a vertex on it,
the opposite vertex in $O$ and with the faces
parallel to the coordinate planes, as sketched.
Then a rotation around the axis $z$ will move any point in the space
keeping fixed the plane orthogonal to z in which they lay , i.e. the $z$ coordinate, along
a circle lying in that plane and centered on the $z$ axis, for an angle measured in that plane.
So $A=(x_1, y_1,z_1)$ will move to $A'=(x_2, y_2,z_1)$ (note z_1 is unchanged) , along
a circle centered at $P$, with radius $r=\sqrt{{x_1}^2+{y_1}^2}$, and angle $\theta$
measured in that plane $z=z_1$.
$S$ will move in that same plane, with the same angle, but on a circle of radius $x_1$.
$Q$ will do the same, on a circle with the same radius, but on the plane $z=0$ along
a circle centered at $O$, with an angle $\theta$ in that plane.
That is to say that the whole parallelepiped $OPSQA$ will rotate keeping fixed the edge
$OP$ and thus rotate to $OPS'Q'A'$, with
$$S'=(x_1 \cos \theta, x_1 \sin \theta, z_1), \; Q'=(x_1 \cos \theta, x_1 \sin \theta, 0)$$
while the expression for $A'$ is a little more complicated.
A: Note that a rotation around the $z$ axis does not change the $z$ coordinate of a point. That means you can perform $A\to A'$ only if $z_2=z_1$. Then the plane $A'PA$ is at a constant $z$ value, so it is parallel to the $x-y$ plane ($z=0$). If you want to see a point on the $x$ axis that is at a distance $x_1$ from $O$, you need to look in the horizontal plane ($x-z$), and draw a parallel to teh $z$ axis from $S$. Then $OPSQ$ looks like a parallelogram.
A: PS= $x_1$ is what you mean.
There does not exist any such point as Q you marked as final coordinate, it is parallel to line $SP$.

A is calculated from A, Q, and P along with a point opposite to origin O , in xz plane, I did not label it .
