Every now and then it's nice to nuke a mosquito.
Let's assume that the path connecting two points $(a,y(a))$ and $(b,y(b))$ can be expressed as a function, and the curve $C(x)$ is given by $C(x) = (x,y(x))$. Then we will proceed using the Calculus of Variations.
The derivative of $C$ wrt $x$ is $(1, y')$, and the functional we want to minimize is the length of the curve $L = \int \|C'\|dx = \int_a^b\sqrt{1 + y' ^2} dx$. If we take $f(x,y,y') = \sqrt{1 + y'^2}$, we get that $\frac{df}{dy} = 0, \frac{df}{dy'} = \frac{y'}{\sqrt{1 + y'^2}}$. Then the Euler-Lagrange equation, sometimes referred to as the fundamental equation of the Calculus of Variations, says exactly that $\dfrac{d}{dx} \left( \frac{y'}{\sqrt{1 + y'^2}}\right) = 0$, which is exactly that $y'$ is a constant.
Thus, if the path connecting the two points is expressible as a function, then the shortest such path is given by a straight line.
EDIT I was certain that someone was in the middle of writing an answer when I typed my tongue-in-cheek response (as so often happens), but as I now see that there is more to add, allow me to extend my answer
The problem here is that we must first define "distance." In the standard Euclidean Plane, the distance between two points is defined to be the length of the line segment between them. So we can drop the word 'shortest' and say that "The distance between any two distant points is the length of the line segment joining them."
Presumably, you want to know that going along any other path will be at least as long. One way of 'seeing this' is that you can approximate any curve with a polygonal path, and these satisfy the triangle inequality, which will make the path longer.
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.
Best Answer
Shivering Soldier gives an answer in rectangular coordinates, for the midpoint of a segment whose endpoints are specified in polar coordinates.
In polar coordinates, that midpoint is at
$$\bigg( \frac{ \sqrt {r^{2}+r'^{2} + 2 r r'\cos (\theta -\sigma) }} 2 , \arctan \frac{r \sin\theta + r' \sin\sigma }{r \cos\theta + r' \cos\sigma}\bigg) $$