There are several ways to specify a line. In Mathematica's graphics, it is done by specifying two points and then connecting the points with the `Line` command. But it is sometimes desirable to parameterize a line, and the most familiar way is the form $y = m x + b$ where $m$ is the slope and $b$ is the offset. This parameterization is particularly awkward for near-vertical lines (where the slope becomes near infinite and numerically sensitive). An alternative is the $(\rho, \theta)$ parameterization which specifies the line as an angle $\theta$ and a distance $\rho$ from the origin, as shown in [the theory section of this wikipedia article](http://en.wikipedia.org/wiki/Hough_transform). The gist is that the line consists of all points $x$ and $y$ for which $\rho = x \cos(\theta) + y \sin(\theta)$, essentially a conversion to polar coordinates. 

Here is a function which takes a pair of points `{p1, p2}` as input in the form `{{x1,y1},{x2,y2}}` and outputs the corresponding $\rho$ and $\theta$:

```
linePolar[{p1_, p2_}] := Module[{},
    {rx, ry} = Rationalize[p1]; {sx, sy} = Rationalize[p2];
    sol = Solve[{rx Cos[t] + ry Sin[t] == rho, 
             sx Cos[t] + sy Sin[t] == rho}, {rho, t}] // N;
    First[Select[{rho, t} //. sol //. C[1] -> 0, #[[1]] >= 0 &]]];

```

For example:

```
linePolar[{{0, -1}, {-1, 0}}]
{0.707107, -2.35619}

```

which shows that the line connecting the two points is `Sqrt[2]/2` away from the origin at an angle of -135 degrees. The almost vertical line

```
linePolar[{{1, -1}, {1.1, 1}}]
{1.04869, -0.0499584}

```

has slope near zero, and the answer appears to be nicely behaved numerically as the line crosses vertical. 

I have two questions. First, it bothers me that the function is essentially re-solving the system of equations each time it is called, and this must be inefficient. Is there a nice way to make it only do the solution once? Second, I would like to have an "inverse" for this function -- something that would take a pair of $(\rho, \theta)$ values and allow it to be plotted. This would be useful because many subsequent calculations need to occur in the $(\rho, \theta)$ space, and it would be good to be able to visualize this by plotting.