ASTAP astrometric solving method (plate solving)  rev 20181215  
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  Find the stars to construct the smallest irregular tetrahedrons. Record tetrahedron edges length and mean position (x,y) of tetrahedrons.  Find the stars to construct the smallest irregular tetrahedrons. Record tetrahedron edges length and mean position (x,y) of tetrahedrons.  
4  Sort the six tetrahedron edges on length for each tetrahedron. e1 is the longest and e6 shortest.  Sort the six edges on length for each tetrahedron. e1 is the longest and e6 shortest.  
5  Scale the tetrahedron edges as (e1, e2/e1,e3/e1,e4/e1,e5/e1,e6/e1)  Scale the tetrahedron edges as (e1, e2/e1,e3/e1,e4/e1,e5/e1,e6/e1)  
6  Find tetrahedrons matches where edges e2 to e6 match within a small tolerance.  
7  For the matching tetrahedrons, calculate the ratio e1_{found}/e1_{reference}
and find the μ (mean), σ (standard deviation) of these ratios. Remove outlier tetrahedrons with a ratio above 3*σ. 

8  From the remaining matching tetrahedrons, prepare the equations: x1,y1,1,xref1 or yref1 x2,y2,1,xref2 or yref2 x3,y3,1,xref3 or yref3 x4,y4,1,xref4 or yref4 ...... 

9  Find solution vector in direction x and y
using above equations using a least square fitting routine. The two resulting solution vectors s: x:=s[0]x+s[1]y+s[2] y:=s[0]x+s[1]y+s[2] Solution of an overdetermined system of linear equations according to the method of least squares using GIVENS rotations. 

10  Convert the x,y position of the image center (standard coordinates) using the solution vector to equatorial α, δ position. Rather then using the solution vector directly, for maximum accuracy use the found vector to find a new vector from the center of the image by one pixel steps from center in direction CRPIX1 and CRPIX2. 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. 
(c) www.hnsky.org, 2018