You can use the sine law to state that
[tex]\dfrac{r}{\sin(y)}=\dfrac{q}{\sin(x)}[/tex]
We can rearrange this equation into
[tex]\dfrac{r}{q}=\dfrac{\sin(y)}{\sin(x)}[/tex]
Now, since this is a right triangle, we have
[tex]x=90-y[/tex]
which implies
[tex]\sin(x)=\sin(90-y)=\cos(y)[/tex]
And so we have
[tex]\dfrac{r}{q}=\dfrac{\sin(y)}{\sin(x)} = \dfrac{\sin(y)}{\cos(y)}=\tan(y)[/tex]