Two particles, $P_1$ and $P_2$, of equal masses $m$ are linked by a spring of stiffness $k$ and natural length $a$. They are sliding freely without friction along a horizontal fixed hoop of radius $R$.
I need some help in writing Lagrangian for generalized coordinates $\theta_1$ and $\theta_2$ given as $\theta_1=\frac{\phi_1+\phi_2}{2}$, $\theta_2=\frac{\phi_1-\phi_2}{2}$.
I wrote that position vectors for $P_1$ and $P_2$ are $\vec r_1$ and $vec r_2$, respectively.
$\vec r_1=-R\cos\phi_1 \vec i+R\sin\phi_1\vec j$
$\vec r_2=R\cos\phi_2\vec i+R\sin\phi_2\vec j$
From this
$\dot{\vec r_1}=R\dot\phi_1\sin\phi_1\vec i+R\dot\phi_1\cos\phi_1\vec j$
$\dot{\vec r_2}=-R\dot\phi_2\sin\phi_2\vec i+R\dot\phi_2\cos\phi_2\vec j$
Kinetic energy is
$T=\frac{1}{2}m(\dot{\vec r_1})^2+\frac{1}{2}m(\dot{\vec r_2})^2=\frac{1}{2}mR^2(\dot\phi_1^2+\dot\phi_2^2)=mR^2(\dot\theta_1^2+\dot\theta_2^2)$
I need help about forces that are doing work.
I know that there is a force in the string, $F=ke$ where $e$ is extension, but I don't know how to determine its direction.
I wrote that
$\vec {P_1P_2}=\vec r_2-\vec r_1$
$|\vec{P_1P_2}|=R\sqrt{2(1+cos(\phi_1+\phi_2))}$ and $|\vec {P_1P_2}|=a+e$
This is all I did. I'm not sure if normal reaction does any work.
Any help would be appreciated.
Left particle is $P_1$, right one is $P_2$, I forgot to write it on the picture.