Skip to content
dirtdigger edited this page Apr 7, 2024 · 1 revision

This page describes the math used in the Calistar spreadsheet:

  • Dimensionality

  • Skew

  • Error propagation

Dimensional error

The dimensional error is the percent difference between the measured and nomial length of the print. For each measured x-length, this is calculated the same for inner- and outer-measurements using

$$ Err_i = \frac{x_i^{Meas} - x_i^{Nominal}}{x_i^{Nominal}}.$$

The value reported in the spreadsheet is the average of all of these relative errors, i.e.

$$ Err = \frac{1}{N_{valid}}\sum_{i:Valid} Err_i $$

where the average is taken only over the number of valid measurements along a given axis and $N_{valid}$ is the number of valid measurements.

Skew angle

See this Stack Exchange discussion for the application of the Law of Cosines to a parallelogram. Adapting the notation in the response, set $p = AC$ and $q = BD$. Then subtracting the first equation from the second to get the angle of the parallelogram:

$$ p^2 - q^2 = 4 ab \cos\alpha $$

$$ \alpha = \cos^{-1}\left(\frac{p^2 - q^2}{4ab}\right). $$

I prefer the form above with all four side lengths because, although in theory there are only three free variables, one uses all of the noisy measurements ($p$, $q$, $a$, $b$) in this formula rather than calculating one from the other three.

You can see how Klipper calculates its skew factor here, which is the same as Marlin. The skew factor is defined as the cotangent of the angle $\alpha$. One can see that the angle $\alpha$ above is equivalent to the one inside of the arc-cosine by solving the second equation in the Stack Exchange for $\alpha$.

Uncertainty quantification of the calculated quantities

One of the main features of the Calistar spreadsheet is uncertainty quantification (UQ) for each of the calculated quantities. What this means is that an error term is associated to each of the calculated quantities (dimensional error and skew). This error term is a result of the uncertainty inherent to using an instrument with finite precision to make your measurements, such as digital calipers.

Why should you care? If the calculated quantity is within 1- or 2-standard deviations of the nominal value (0% for dimensional error and 0 degrees for skew), then you probably can't improve it any more, at least not in any measureable way. You might actually make it worse if you try!

Propagation of error

Error is estimated by calculating the gradient vector $G$ of each of the quantities being calculated with respect to each of the elementary measurements that are taken. Then, this Jacobian is used with a diagonal covariance matrix $\Sigma$ that describes the variance of the measured quantities to calculate

$$ G\Sigma G^\top,$$

where $G$ is represented as a row vector. This is the variance of the calculated quantity. See propagation of uncertainty on Wikipedia for the theoretical basis for this.

Uncertainty estimation of dimensional error

The derivative of the error term given above with respect to the $i$ th measurement is

$$ \frac{\partial}{\partial x_i^{Meas}} Err = \frac{1}{N_{valid}x_i^{Nominal}}.$$

Hence the variance of the calculated dimensional error is

$$ \sigma_{Err}^2 = \frac{1}{N_{valid}^2}\sum_{i:Valid}(\frac{\sigma_i}{x_i^{Nominal}})^2.$$

Note that the dimensional error is an affine function of the measurements, so this calculation is exact.

Uncertainty estimation estimation for skew

It takes some work to calculate by hand, but one can verify

$$ \frac{\partial\alpha}{\partial q} = \frac{q}{2ab\sin(\alpha)} $$

$$ \frac{\partial \alpha}{\partial p} = -\frac{p}{2ab\sin(\alpha)} $$

$$ \frac{\partial \alpha}{\partial a} = \frac{p^2-q^2}{4a^2b\sin(\alpha)} $$

$$ \frac{\partial \alpha}{\partial b} = \frac{p^2-q^2}{4ab^2\sin(\alpha)}. $$

Hence the variance in $\alpha$ is approximately

$$ \sigma_\alpha^2 = \frac{1}{4a^2b^2\sin^2\alpha}\left[ (q\sigma_q)^2 + (p\sigma_p)^2 + (\frac{p^2-q^2}{2a}\sigma_a)^2 + (\frac{p^2-q^2}{2b}\sigma_b)^2\right].$$

Clone this wiki locally