ASTAP astrometric solving method (plate solving)  rev 2018927  
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 triangular pyramids. Record pyramid edges length and mean position (x,y) of pyramids.  Find the stars to construct the smallest triangular pyramids. Record pyramid edges length and mean position (x,y) of pyramids.  
4  Sort the six pyramid edges on length for each pyramid. e1 is the longest and e6 shortest.  Sort the six edges on length for each pyramid. e1 is the longest and e6 shortest.  
5  Scale the pyramid edges as (e1, e2/e1,e3/e1,e4/e1,e5/e1,e6/e1)  Scale the pyramid edges as (e1, e2/e1,e3/e1,e4/e1,e5/e1,e6/e1)  
6  Find pyramids matches where edges e2 to e6 match within a small tolerance.  
7  For matching pyramids, calculate the ratio e1/e1 and find mean, σ (standard deviation) of e1. Remove outlier pyramids above 3* σ.  
8  From matching pyramids, 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, 2019