My application is that I have a cheap Chinese CNC machine where the X and Y axes are not quite orthogonal. They are close, but not quite there, and I'd like to measure the angle between the axes so as to adjust the machine and bring them closer to being orthogonal.
Translating (as best I can) into maths, we have a skew coordinate system where x' = x, and y' is at an angle (close to pi/2) from x. We can make marks in x' and y', and we can measure accurately in x' and y' (I use a microscope and a small drill bit, and move the bit until it is over the mark). But we cannot make marks in x,y, nor can we measure (nearly as) accurately in x,y.
I've already figured out that what I do is drill three holes in a piece of waste material at (x',y') = (0,0) (a,0) (0,b), then take that piece of waste material, flip it in y, and measure where the three holes appear on the other side. Of course we won't be able to quite flip it in y - there will be a different small angle between the y axis and the actual axis of reflection (it's a really cheap machine!).
So I measure the three holes post-flip at (0,0) (a',0) and (0,b') (NO - SEE BELOW!). Now I'm going to assume that the x' and y' axes on my machine have the same scale. How do I go from a, b, a' and b' to the angle (let's call it theta) between the x' and y' axes? Especially since I don't know the precise angle between the axis of reflection and the y axis (let's call it psi)? I've looked at this geometrically and I believe it should be possible, but the I keep making mistakes when I try and do the maths.
Thanks.
EDIT: OK I'm an idiot. Post-flip the holes will be at (0,0) (a'x, a'y) and (b'x, b'y). Both a'y and b'x should be close to zero, but they will not be zero!
CLARIFICATION: I'm aiming for an accuracy of 50 micrometers across 100 millimeters or better. I seem to be able to measure and cut with that accuracy, and it is an accuracy I need for my ultimate application (double-sided PCB milling).
My thoughts: There are four translations involved. We go from (x',y') to (x,y), then to (-x,y), then through a rotation psi, then to our new (x',y'). That's four matrix multiplications, whose result I imagine would be a mess! Then trying to solve for theta (and probably psi) would also be a mess! I'm wondering if an iterative approach would be better? Given psi figure out how to calculate theta, and given theta figure out how to calculate psi? Because we can make a good initial guess of psi = 0 and theta = pi/2.
Edit: There are suggestions that I use a caliper to take measurements and then apply simple geometry to find the answer. I've done a very quick test - getting my caliper to make sub-50-micrometer movements while keeping it still enough so that it doesn't drift off the far hole is really difficult - calipers are built to butt up against measurement points. I'd have to get machined pins and matching drill bits or something. What I might do is take advantage of the power of computers, and write some silly code using a generic minimising algorithm. That would have advantages that I could throw more data points at it, it would do its best with any inaccuracies in measurement, it could handle any other misalignments in the CNC machine (though the machine seems to be quite well aligned otherwise), and it could give me error estimates. Thanks.
This solution will work even if $x'$ and $y'$ are not of the same scale, or the machine's true axes are far from orthogonal.
Drill holes $O,A,B$ at $(x',y')=(0,0),(0,p),(p,0)$ for any convenient $p$. Measure the side lengths of $\triangle AOB$ as $AO=a,OB=b,AB=c$.
$\theta$, the angle between the machine's axes, is $\angle AOB$ and can be found with the cosine rule. Since precision is demanded, a numerically stable variant should be used: $$\theta=2\sin^{-1}\sqrt{\frac{(c+a-b)(c+b-a)}{4ab}}$$