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°
Best Answer
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).$$