NAME:
  astterms
 PURPOSE:
  Evaulate the independent vectors to match an astrometric polynomial function.
 DESCRIPTION:

  This function is a support routine to ASTROM and handles part of the
  transformation between pixel (x,y) coordinates and the tangent plane
  coordinates (xi,eta).  The transformation from (ra,dec) to (xi,eta)
  is not handled in this routine.  The premise is that the transformation
  from the tangent plane to pixel coordinates can be done with a polynominal.
  I have implemented all of the common terms found in typical astrometric
  solutions.  In practice, the high order terms are probably not needed
  except for very large fields or for highly distorted fields caused by
  excessive optics.  Most CCD fields can be accurately modeled using just
  the linear terms.

  This function does NOT actually evaluate the transformation.  Instead,
  the independent values for the polynominal are computed.  The result is
  an array with (nterms,nvals) elements where nterms is the number of
  non-zero terms and nvals is the number of input x and y values (which must
  be of the same length.  The table below lists the contents of the i^th
  column in the output array.

 CATEGORY:
  Astrometry
 CALLING SEQUENCE:
  val=astterms(x,y,terms)
 INPUTS:
  x     - X - coordinate (scalar or vector)
  y     - Y - coordinate (scalar or vector)
  terms - Which terms are to be built, if this input is a 10-element
             integer array, then a 1 means use the term,
                                   0 means don't use it.
              0 - const (always use this)
              1 - x     (always use this)
              2 - y     (always use this)
              3 - r
              4 - x^2
              5 - y^2
              6 - x^3
              7 - y^3
              8 - xy^2
              9 - yx^2
         Another input option is provide where terms is an string array
            that contains the name of the term.  The terms can appear in
            any order and any subset can be used.  There is NO error
            checking to prevent duplicating a term (to save time).  The
            terms that are supported are (the names must match, case is
            ignored):
            CONST, X, Y, XX, YY, XY, R (sqrt(x^2+y^2)), XXX, YYY, XYY, XXY,
            XXXX, YYYY, XYYY, XXYY, XXXY, XXXXX, YYYYY, XYYYY, XXYYY, XXXYY,
            XXXXY, T1, T2, T3, T4, T5, U1, U2, U3, U4, U5

         The terms labeled 'T' and 'U' are Chebyshev polynomials, with order
            begin given by the repetition of X or Y, (ie., TXX is second order
            of degree 1; TXYYY is 1st order in X times 3rd order in Y for
            degree 1.
         Complete list: (CONST applied to all forms)
            degree 1
            TX, TY, TXX, TXY,TYY, TXXX, TXXY, TXYY, TYYY,
            TXXXX, TXYYY, TXXYY, TXXXY, TYYYY,
            TXXXXX, TXYYYY, TXXYYY, TXXXYY, TXXXXY, TYYYYY
            degree 2
            UX, UY, UXX, UXY, UYY, UXXX, UXXY, UXYY, UYYY,
            UXXXX, UXYYY, UXXYY, UXXXY, UYYYY,
            UXXXXX, UXYYYY, UXXYYY, UXXXYY, UXXXXY, UYYYYY

         The terms labeled L are Legendre polynomials with M=0
            PX, PY, PXX, PXY, PYY, PXXX, PXXY, PXYY, PYYY,
            PXXXX, PXYYY, PXXYY, PXXXY, PYYYY,
            PXXXXX, PXYYYY, PXXYYY, PXXXYY, PXXXXY, PYYYYY

 OPTIONAL INPUT PARAMETERS:

 KEYWORD INPUT PARAMETERS:

 OUTPUTS:
  return value - Dependent value(s), if x,y was 1-d then this will be scalar.

 KEYWORD OUTPUT PARAMETERS:

 COMMON BLOCKS:

 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURE:

 MODIfICATION HISTORY:
  1997/06/17, Written by Marc W. Buie, Lowell Observatory
  2009/10/25, MWB, added string input option for terms
  2009/12/10, MWB, added 4th order terms (names option only)
  2010/02/24, Chris Sauro, added Chebyshev terms
  2010/02/28, MWB, filled out Chebyshev and added Legendre
  2010/03/31, MWB, added 6th order Legendre