ASTAP astrometric solving method (plate solving)  rev 20191028  
Image  Star database  
1  Find background, noise and star level  
2  Find stars and their CCD x, y position (standard coordinates)  Extract a similar amount of stars for the area of interest from the star database that matches the star density of the image. Convert the α, δ equatorial positions into standard coordinates (CCD pixel x,y coordinates for optical projection) using the rigid method. 

3  Use the extracted stars to construct the smallest irregular tetrahedrons of four stars (quads). Calculate the length of the six tetrahedron edges in pixels and the mean x, y position of tetrahedrons.  Use the extracted stars to construct the smallest irregular tetrahedrons of four stars (quads). Calculate the length of the six tetrahedron edges in pixels and the mean x, y position of tetrahedrons.  
4  Sort the six tetrahedron edges on length for each tetrahedron. e_{1} is the longest and e_{6} shortest.  Sort the six tetrahedron edges on length for each tetrahedron. e1 is the longest and e6 shortest.  
5  Scale the tetrahedron edges as (e_{1}, e_{2}/e_{1},e_{3}/e_{1},e_{4}/e_{1},e_{5}/e_{1},e_{6}/e_{1})  Scale the tetrahedron edges as (e_{1}, e_{2}/e_{1},e_{3}/e_{1},e_{4}/e_{1},e_{5}/e_{1},e_{6}/e_{1}))  
6  Find tetrahedrons matches where edges e_{2}/e_{1} to e_{6}/e_{1} match within a small tolerance.  
7  For the matching tetrahedrons, calculate the size ratio e1_{found}/e1_{reference}
and find the μ (mean), σ (standard deviation) of these ratios. Remove the outlier tetrahedrons with a ratio above 3*σ. 

8  From the remaining matching tetrahedrons, prepare the "A"
matrix/array containing the x,y center positions of the test image
tetrahedrons in standard coordinates and the arrays X_{ref}, Y_{ref} containing the x, y center positions of the reference image tetrahedrons in standard coordinates. A: S_{x}: X_{ref}: [x_{1} y_{1} 1] [a] [X_{1}] [x_{2} y_{2} 1] * [b] = [X_{2}] [x_{3} y_{3} 1] [c] [X_{3}] [x_{4} y_{4} 1] [X_{4}] [._{.} ._{.} .] [._{.}] [x_{n} y_{n} 1] [X_{n}] A: S_{y}: Y_{ref}: [x_{1} y_{1} 1] [d] [Y_{1}] [x_{2} y_{2} 1] * [e] = [Y_{2}] [x_{3} y_{3} 1] [f] [Y_{3}] [x_{4} y_{4} 1] [Y_{4}] [._{.} ._{.} .] [._{.}] [x_{n} y_{n} 1] [Y_{n}] Find the solution matrices S_{x} and Sy of this overdetermined system of linear equations. The solutions S_{x} and S_{y} describe the six parameter plate solution X_{ref}:=a*x + b*y + c and Y_{ref}:=d*x + e*y +f. 

9  With
the solution and the equatorial center position of the reference image
the test image center equatorial position, α and δ can be
calculated. Make from the test image center small one pixel steps in x, y and use the differences in α, δ to calculate the image scale and orientation. This is the final solution. The solution vector (for position, scale, rotation) can be stored as the FITS keywords crval1, crval2, cd1_1,cd1_2,cd_2_1, cd2_2. 
Version: 20191028
(c) Han Kleijn, www.hnsky.org, 2018, 2019