Help with skew correction

I'm having trouble figuring out the math on measuring the diagonals on a square. The stl linked in the documentation isn't very good.
Here is how I've been approaching the problem.
My steps/mm are on point and measure up just fine in the x and y direction, but the diagonals do not match up. Also wouldn't mesh bed leveling correct for any xz and yz deviation and would not be needed with mesh bed leveling?

What is the length of the side of the square in the first image? If we call that <side> then the M556 command you need is either:
M556 S<side> X0.97
or
M556 S<side> X0.97
I'm sorry, it's years since I used axis skew compensation so I can't remember which.
You are right that mesh bed compensation could compensate for XZ and YZ skew instead of using M556. Better still, level the bed so that it is perpendicular to the XY movement plane.

@dc42 thank you for the response. I understand the gcode command I think. It's measuring rise over run per mm. You type in the length and offset value and it reduces it to a 1mm value. My question is more of a geometry problem. Say solidworks says side a and b are 100mm and side c should be 141.421mm, but I'm measuring 143mm because side a and b are not perpendicular. I'm using solidworks to draw directly on the object because is been 20yrs since geometry and trig and I can't quite be confidant/remember my math.
If some one knows a simple formula to get the offset from just measuring the diagonal of a triangle given two sides of equal length, that would work.
What I'm attempting to do is anchor the bottom leg of the triangle horizontal and letting the top leg of the swing freely. Then define the "hypotenuse" which in this case makes the triangle a little obtuse. Then measure from the, from my example above, 100mm correct leg horizontally to the "measured side b".
Is this method sound? I can't be sure I'm correct in my approach. I believe you should be able to measure skew just by measuring just the hypotenuse of a triangle knowing what legs a and b are.

I would think there would be a formula like
Offset=sin(a*b)tan(c)It seems like this would be a common text book trig problem and maybe someone in the community would look at this and easily know the answer to. I've been trying to google the problem, but don't know the exact phrases to search leading me nowhere.

I think it's better to fix the mechanical error than to compensate for it. You may have other ideas.
If you're trying to fix the physical skew, there is a spreadsheet that will calculate the error based on diagonal measurements and the necessary corrections. See: https://www.youmagine.com/designs/alignmentandcalibrationcube

@mrehorstdmd Thanks! Glancing over the sheet it looks right. As for correcting the mechanical error the only precision tool I have is my pair of calipers. None of the squares at the local hardware store agree with one another so I can't know which one to trust. I don't want or have an entire machine shop at my disposal, just an ender 3 to slowly build upon as I learn the hobby. I've gotten it as close as I can by using best assembly practices from multiple youtube and reddit posts. I'm ok with letting software correcting the last little bit to get the utmost out of this cheap frame. I'm happy this feature exists and feel like it exists for newbs like me

@xxsteven69xx You can test a square for squareness by drawing a line with it, then flipping it over and seeing if the line you drew lies along the edge of the square. See https://www.youtube.com/watch?v=enEYzTXg2Jg about 2 minutes in...

@mrehorstdmd Very useful! You've shown me 2 things today. You sir are a gentleman and a scholar. Thanks.