A ladder $AB$ of mass $m$ has its ends on a smooth wall and floor (see figure). The foot of the ladder is tied by an inextensible rope of negligible mass to the base $C$ of the wall so the ladder makes an angle $\alpha$ with the floor. Using the principle of virtual work, find the magnitude of the tension in the rope.
My equations:
I assume length of ladder = $L$
$x$-direction: $$N_2 = mg$$
$y$-direction: $$N_1 = T$$
torque equation about $B$: $$ T_{about B}=T_{mg}+T_{A} = \frac{L}{2}(mg)cos\alpha-LN_1 sin\alpha=0$$ Therefore, $$\frac{L}{2}(mg)cos\alpha-LT sin\alpha=0$$
And we get $$T= \frac{1}{2}(mg)cot\alpha$$
which is the answer.
However, I am supposed to find this using the principle of virtual work. To do this, I guess I would have to displace the ladder downward at $A$ and rightward at $B$, in which case the normal forces $N_1$ and $N_2$ do no work. I then conclude that the work done by the gravitational force $mg$ along the downward displacement of the center of mass of the ladder counterbalances the tension times the horizontal displacement at $B$. However, finding the displacement of the center of the ladder as the ladder slides downwards doesn't seem to be an easy task, so I must be on the wrong track. The final equation I have to deal with seems to be $$mg.\delta y_{com}-T.\delta x_{at B}=0$$
Any inputs would be appreciated.