function transmatrix

Compute the transformation matrix for two reference coordinate systems. It is described by a first order polynomial if the number of reference sources is <= 6, else a second order polynomial is used. The transformation function will be calculated using a least squares fit to given coordinates. Note that if either in REFSTARS or in IMSTARS a coordinate is exactly (-1, -1), this star will not be used to calculate the transformation matrix.

Syntax
result = transmatrix(REFSTARS, IMSTARS [, xerror, yerror][, /silent] [, /linear] [, /cubic] [, /rotation])

Arguments
REFSTARS:   A matrix 2xm (m >= 3) with positions of the reference stars in the reference frame (= masterlist)
IMSTARS:   A matrix 2xm (same size as REFSTARS) with the positions of the same stars in the image to be transformed.
xerror:   If set to a named variable, the residual error of the coordinate transform in the first axis is returned.
yerror:   If set to a named variable, the residual error of the coordinate transform in the second axis is returned.


Switches
/silent:   Printing of output is suppressed
/linear:   A 1st order polynomial is fitted (even when more than 6 reference sources are supplied)
/cubic:   A 3rd order polynomial is fitted (at least 10 reference sources)
/rotation:   A rotational transformation is fitted (at least 4 reference sources): x' = x0 + f*cos(a)*x - f*sin(a)*y, y' = y0 + f*sin(a)*x + f*cos(a)*y


Returns
For 1st and 2nd order polynomials: A matrix 2x6 which describes the coordinate transformation matrix:
   x' = result[1,1] + result[1,2]*x + result[1,3]*y + result[1,4]*xy + result[1,5]*x^2 + result[1,6]*y^2
   y' = result[2,1] + result[2,2]*x + result[2,3]*y + result[2,4]*xy + result[2,5]*x^2 + result[2,6]*y^2
For 3rd order polynomials: A matrix 2x10 which describes the coordinate transformation matrix:
   x' = result[1,1] + result[1,2]*x + result[1,3]*y + result[1,4]*xy + result[1,5]*x^2 + result[1,6]*y^2 + result[1,7]*x^2y + result[1,8]*xy^2 + result[1,9]*x^3 + result[1,10]*y^3
   y' = result[2,1] + result[2,2]*x + result[2,3]*y + result[2,4]*xy + result[2,5]*x^2 + result[2,6]*y^2 + result[2,7]*x^2y + result[2,8]*xy^2 + result[2,9]*x^3 + result[2,10]*y^3
For rotational transformation: A matrix 1x4 which describes the coordinate transformation matrix:
   x' = result[1] + result[3] * cos(result[4])*x - result[3] * sin(result[4])*y
   y' = result[2] + result[3] * sin(result[4])*x + result[3] * cos(result[4])*y

See also
function transcoords
function transform