Calculating rectangle corners location in rotating around a pivot line I'm trying to transform shapes in an Android app by rotating them around a pivot line (using View.setRotationY). As you see in the below images, I rotate the shape around the green line which is parallel to the vertical axis and crossed the center point of the rect. Looking at its 2D drawing makes sense that the left edge comes forward and the right edge goes backward.
Now I want to formulate it. I mean the length of the edges based on rotation angle as well as their movement.

Any suggestions are really appreciated.

Rotation Angle: 0°



Rotation Angle: 15°



Rotation Angle: 30°



Rotation Angle: 45°



Rotation Angle: 60°



Rotation Angle: 75°



Rotation Angle: 90°
Assuming a square of sides 2 units, the spatial coordinates of the four vertices are

$$(x,y,z)=(r\cos\theta,s,r\sin\theta)$$ where the $r$ and $s$ are $\pm1$ independently, and $\theta$ is the rotation angle around the vertical axis ($y$).

Now their perspective projection, assuming the viewpoint at $f$ units in the direction of the $z$ axis is

$$(X,Y)=\left(\frac{fx}{z+f},\frac{fy}{z+f}\right)=\left(\frac{fr\cos\theta}{r\sin\theta+f},\frac{fs}{r\sin\theta+f}\right).$$
Assume the edge length at zero angle is $a$ and the edge length at 90-degree angle is $b$, you may formulate the edge length as function of the rotation angle $\theta$ as,

$$L(\theta) = b\sin\theta + a(1-\sin\theta)$$

Such a relationship is based on the assumption that the edge length varies linearly with respect to the front-back distance.