Q: Construction of a circle through a point and tangent to angle given an angle $\angle (h,k)$, where $h,k$ are  the legs of the angle. Let $P$ be some point in the interior of the angle. 
I want to construct a circle through P which is tangent to both legs $h,k$. 
First I drew the angle bisector, for the center of the circle must lie on it in order to be tangent to $h,k$. But I could not accomplish to find the origin on the angle bisector. Can someone help me please?
Best wishes

A: Let your angle $\angle (h,k)$ be given as angle $\angle BAC$ in this diagram, with $h=\overrightarrow {AB}$ and $k=\overrightarrow {AC}$.

Draw the ray $\overrightarrow{AP}$. Place any point $D$ on the bisector of $\angle (h,k)$ and draw the circle centered at $D$ tangent to both rays $h$ and $k$. Let the intersections of circle $D$ with ray $\overrightarrow{AP}$ be points $F$ and $G$.
Draw segments $\overline{DF}$ and $\overline{DG}$. Place points $H$ and $I$ on ray $\overrightarrow{AD}$ such that segment $\overline{PH}$ is parallel to segment $\overline{DF}$ and segment $\overline{PI}$ is parallel to segment $\overline{DG}$. Draw a circle with center $H$ and radius $HP$ as well as a circle with center $I$ and radius $IP$.
Then circles $H$ and $I$ will be tangent to rays $h$ and $k$ and will be your desired circles.
This construction works because the figure of circle $D$ with point $F$ is similar to circle $H$ with point $P$, and also the figure of circle $D$ with point $G$ is similar to circle $I$ with point $P$. In other words, we made a "trial" circle first at $D$ then expanded it with the correct proportions to the circles we wanted.

A: Let's transform the coordinate system 
such that 
$O=(0,0)$, 
bisector coincides with $x$-axis and
$\angle A_1OB_1=2\phi$:

Let the distance to the center of the circle $|OQ_1|=t$.
Then 
$r_1^2=|Q_1A_1|^2=(t\sin(\phi))^2$.
On the other hang, 
$r_1^2=|Q_1P|^2=|Q_1E|^2+|EP|^2
=(P_x-t)^2+P_y^2$.
Equating right hand sides of the two
expressions for the radius $r_1$,
we can build and solve a quadratic equation 
\begin{align}
(t\sin(\phi))^2&=(P_x-t)^2+P_y^2
\\
\cos^2(\phi)t^2-2P_x t+(P_y^2+P_x^2) &= 0
\end{align}
and get distances $t_1,t_2$ to the centers of the circles
\begin{align}
t_{1,2}&=\frac{P_x \mp \sqrt{P_x^2-(P_y^2+P_x^2)\cos^2(\phi)}}{\cos^2(\phi)}
\end{align}
in terms of known coordinates of the point $P=(P_x,P_y)$ 
and the angle $\phi$.
The centers and the radii 
of two circles are then
\begin{align}
Q_1&=(t_1,0),\quad Q_2=(t_2,0),
\\
r_1&=t_1\sin(\phi),\quad r_2=t_2\sin(\phi).
\end{align}
Also, from right triangles 
$\triangle A_1OQ_1$ and
$\triangle A_1OD_1$
the tangent points of the first circle
\begin{align}
A_1&=(t_1\cos^2(\phi), t_1\cos(\phi)\sin(\phi)),
\\
B_1&=(t_1\cos^2(\phi),-t_1\cos(\phi)\sin(\phi)).
\end{align}
Similarly, from
$\triangle A_2OQ_2$ and
$\triangle A_2OD_2$
the tangent points of the second circle
\begin{align}
A_2&=(t_2\cos^2(\phi), t_2\cos(\phi)\sin(\phi)),
\\
B_2&=(t_2\cos^2(\phi),-t_2\cos(\phi)\sin(\phi)).
\end{align}
