next up previous
Next: Variable Numbers of Coordinates
Up: Creating Your Own Private Mappings (IntraMaps)
Previous: Creating an IntraMap

Restricted Implementations of Transformation Functions  

You may not always want to use both the forward and inverse transformations when you create an IntraMap, so it is possible to omit either from the underlying coordinate transformation function. Consider the following, for example:

void Poly3Tran( AstMapping *this, int npoint, int ncoord_in,
                const double *ptr_in[], int forward, int ncoord_out,
                double *ptr_out[] ) {
   double x;
   int point;

/* Forward transformation. */
   for ( point = 0; point < npoint; point++ ) {
      x = ptr_in[ 0 ][ point ];
      ptr_out[ 0 ][ point ] = ( x == AST__BAD ) ? AST__BAD :
         6.18 + x * ( 0.12 + x * ( -0.003 + x * 0.0000101 ) );
   }
}

This implements a 1-dimensional cubic polynomial transformation. Since this is somewhat awkward to invert, however, we have only implemented the forward transformation. When registering the function, this is indicated via the ``flags'' argument to astIntraReg, as follows:

void Poly3Tran( AstMapping *, int, int, const double *[], int, int, double *[] );

...

astIntraReg( "Poly3Tran", 1, 1, Poly3Tran, AST__NOINV,
             purpose, author, contact );

Here, the fifth argument has been set to the flag value AST__NOINV to indicate the lack of an inverse. If the forward transformation were absent, we would use AST__NOFOR instead. Flag values for this argument may be combined using a bitwise OR if necessary.



next up previous
Next: Variable Numbers of Coordinates
Up: Creating Your Own Private Mappings (IntraMaps)
Previous: Creating an IntraMap

AST A Library for Handling World Coordinate Systems in Astronomy
Starlink User Note 211
R.F. Warren-Smith & D.S. Berry
30th April 2003
E-mail:ussc@star.rl.ac.uk

Copyright (C) 2003 Central Laboratory of the Research Councils