Yesterday it took me all night to learn that single precision numbers and double precision numbers are not at all the same thing. Not that Matlab will tell you this, of course. They'll look exactly the same to the untrained eye. No, you have to specifically ask, using an obscure function such as superiorfloat(). All Matlab will do is inexplicably refuse to make straightforward plots of those numbers until after you change them.
Today I learned that it's quite difficult to rotate the axes of a cartesian system to anything other than 90 degrees, especially if you've never learned any math past calculus (and you didn't do so good in calculus).
[lat_rotate,lon_rotate] = rotatem(lat, lon, origin, 'forward', 'degrees');
... which will indeed do some rotating of the data. However, the end result won't bear much resemblance to what you had at the start.
Then (via John) there's:
xdist = sqrt(((m*lat - m*b) ./ (1 + m^2)).^2 + (((1-m^2)*lat - b + b*m^2 + m*lon) ./ (1 + m^2)).^2);
xdist = sqrt((((lon + m*lat + m*b) / (m + 1/m)) + b - lat).^2 + (((lon/m + lat + b) / (m + 1/m)) - lon).^2);
... which uses linear algebra and vectors and dot products and all sorts of stuff that go completely over my head. I have no clue how the equations got derived, only that they don't seem to do what I want them to, and I don't know how to fix them. Also it occurred to me while I was fiddling with them that they'll only give me the x values, not the y values...
Snave tells me it's simple. Those matrices look scary to me. o.O
On Monday I'll reveal my utter ignorance to the local Matlab expert, and maybe she'll figure out how to do all this for me. Either that or I'll abandon this foray and go to Plan B (which is to do what my boss actually asked for as opposed to what he wants (and will probably be asking for when he finds out that what he asked for won't be sufficient)).