Measuring the angle between skew coordinate axes using the skew coordinates 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.
 A: Suppose you drill holes at $(x',y')$ coordinates $(0,0),$ $(a,0),$ $(-a,0),$ and $(b,0),$ then cut the piece in two along the line $x'=0,$ using a thin enough saw that part of each hole along that line is still visible in each piece. Put both pieces upright with the cut edge supported by rollers in each of the holes. (Use rollers of a slightly smaller diameter than the drill, resting on a flat surface.) This will effectively "fold" the piece along the line $x'=0,$ and the error in the angle between the axes will be measurable by the distance between the centers of the $(\pm a,0)$ holes.
Specifically, if the distance between the centers of the $(\pm a,0)$ holes
is $d$ after "folding" the piece, the angle between the axes of the machine is
$$\frac\pi2 \pm \arcsin\frac{2a}{d}.$$
You can deduce which sign to use for the $\pm$ by seeing in which direction the holes are offset.
This being such a poorly made machine, you might want to use your own instruments to measure the distances between the center of the hole drilled at $(x',y')=(0,0)$ and the centers of the $(\pm a,0)$ holes. If the measurements are the same you can substitute the new measurement for the value $a$ calibrated by the machine, though this probably will have little impact on the calculated angle.
More important is that if you find a difference in the measurements that is within a couple of orders of magnitude of $d,$ you may want to take that into account in the formula.
Mathematically, the angle could be found via the Law of Cosines in that case,
but in practice the arc cosine of a very small angle tends to be miscalculated;
instead, a good approximation would be to set $d_1 = \sqrt{d^2 - (a_1 - a_2)^2},$ where $a_1$ and $a_2$ are the two measurements, and then the angle is
$$\frac\pi2 \pm \arcsin\frac{a_1 + a_2}{d_1},$$
or even
$$\frac\pi2 \pm \frac{a_1 + a_2}{d_1}$$
since the angle is (apparently) small enough to make this a good approximation.
A: 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}}$$
