### SLA_FITXY

Fit Linear Model to Two $\left[\phantom{\rule{0.3em}{0ex}}x,y\phantom{\rule{0.3em}{0ex}}\right]$ Sets

ACTION:
Fit a linear model to relate two sets of $\left[\phantom{\rule{0.3em}{0ex}}x,y\phantom{\rule{0.3em}{0ex}}\right]$ coordinates.
CALL:
CALL sla_FITXY (ITYPE, NP, XYE, XYM, COEFFS, J)
##### GIVEN:
 ITYPE I type of model: 4 or 6 (note 1) NP I number of samples (note 2) XYE D(2,NP) expected $\left[\phantom{\rule{0.3em}{0ex}}x,y\phantom{\rule{0.3em}{0ex}}\right]$ for each sample XYM D(2,NP) measured $\left[\phantom{\rule{0.3em}{0ex}}x,y\phantom{\rule{0.3em}{0ex}}\right]$ for each sample

##### RETURNED:
 COEFFS D(6) coefficients of model (note 3) J I status: 0 = OK $-$1 = illegal ITYPE $-$2 = insufficient data $-$3 = singular solution

NOTES:
(1)
ITYPE, which must be either 4 or 6, selects the type of model fitted. Both allowed ITYPE values produce a model COEFFS which consists of six coefficients, namely the zero points and, for each of XE and YE, the coefficient of XM and YM. For ITYPE=6, all six coefficients are independent, modelling squash and shear as well as origin, scale, and orientation. However, ITYPE=4 selects the solid body rotation option; the model COEFFS still consists of the same six coefficients, but now two of them are used twice (appropriately signed). Origin, scale and orientation are still modelled, but not squash or shear – the units of X and Y have to be the same.
(2)
For NC=4, NP must be at least 2. For NC=6, NP must be at least 3.
(3)
The model is returned in the array COEFFS. Naming the six elements of COEFFS $a,b,c,d,e$ & $f$, the model transforms measured coordinates $\left[{x}_{m},{y}_{m}\phantom{\rule{0.3em}{0ex}}\right]$ into expected coordinates $\left[{x}_{e},{y}_{e}\phantom{\rule{0.3em}{0ex}}\right]$ as follows:

${x}_{e}=a+b{x}_{m}+c{y}_{m}$
${y}_{e}=d+e{x}_{m}+f{y}_{m}$

For the solid body rotation option (ITYPE=4), the magnitudes of $b$ and $f$, and of $c$ and $e$, are equal. The signs of these coefficients depend on whether there is a sign reversal between $\left[{x}_{e},{y}_{e}\right]$ and $\left[{x}_{m},{y}_{m}\right]$; fits are performed with and without a sign reversal and the best one chosen.
(4)
Error status values J=$-$1 and $-$2 leave COEFFS unchanged; if J=$-$3 COEFFS may have been changed.
(5)