finding the intersections of two polar angles on a segment You are given a point Q and a segment defined by end points A and B.

Given two polar angles a and b that are created by Q,
how can you find the two intersection points of the two lines (going through Q and having these polar angles) and the segment defined by A, B?
In the picture above it looks like the intersections are just the two segment end points, but the polar angles can be anything.
I took the above picture from another problem that I wanted to solve, which was given a point Q and a segment A,B find polar angles a and b.
 A: To find the points on a line $\ell$ at polar angles $a$ and $b$ relative to $Q,$
first obtain an equation for the line $\ell.$
Exactly how you go about doing that will depend on how the line $\ell$ was described
in the first place.
Supposing that the line was described in terms of $x,y$-coordinates, however,
in general it has an equation equivalent to
$$ px + qy = k $$
where $p,$ $q,$ and $k$ are some constant parameters.
(This form is a little more general than the usual "function of $x$" form,
$y = mx + k,$ because it can describe a vertical line.)
We can convert this equation into an equation for the line in polar coordinates
by substituting $x = r \cos\theta$ and $y = r \sin\theta$ at an arbitrary
point $(x,y)$ on the line. Plugging these values into the equation above, we have
$$ p(r \cos\theta) + q(r \sin\theta) = k $$
which we can rewrite as
$$ (p \cos\theta + q \sin\theta)r = k $$
and therefore
$$ r = \frac{k}{p \cos\theta + q \sin\theta}. $$
So we see that $r$ is a function of $\theta,$ and this last equation gives
a way to compute $r$ directly from any value of $\theta.$
For example, to compute the coordinates of the point $A$ at polar angle $a,$
we set
$$ r_A = \frac{k}{p \cos a + q \sin a}. $$
The $x,y$-coordinates of this point are then
$$\begin{eqnarray}
x_A &=& r_A \cos a = \frac{k \cos a}{p \cos a + q \sin a},\\
y_A &=& r_B \sin a = \frac{k \sin a}{p \cos a + q \sin a}.
\end{eqnarray}$$
If $\cos a \neq 0$ we can write
$$\begin{eqnarray}
x_A &=& \frac{k}{p + q \tan a},\\
y_A &=& x_A \tan a.
\end{eqnarray}$$
If $\cos a = 0,$ of course, $x_A = 0$ and $y_A = \frac kq.$
The coordinates of point $B$ can similarly be expressed in terms of
$\cos b$ and $\sin b.$
Note that for some values of $\theta,$ the polar equation of the line gives
a negative value of $r.$  This is perfectly legitimate; if $(r,\theta)$ are
polar coordinates of a point then $(-r,\theta + \pi)$ are polar coordinates
of the same point (and so are $(r,\theta + 2n\pi)$ for any integer $n$).
If you compute $r_A$ explicitly then of course you will know when it is negative;
if you use a formula that does not explicitly compute $r_A$
then you can tell that $r_A$ is negative if $\cos a$ and $x_A$ have
opposite signs.
If $x_A = 0$, then $r_A$ is negative if $\sin a$ and $y_A$ have opposite signs.
