Consider a simple example based on two 2-dimensional coordinate
systems. Suppose that to convert from one to the other we must swap
the coordinate order and multiply both coordinates by 5, so that the
coordinates () transform into (
). This can be done
in two stages:
The PermMap and ZoomMap are then said to operate in series,
because they are applied sequentially
(c.f. Figure ). We can create a CmpMap
that applies these Mappings in series as follows:
#include "ast.h" AstCmpMap *cmpmap; AstPermMap *permmap; AstZoomMap *zoommap; ... /* Create the individual Mappings. */ { int inperm[ 2 ] = { 2, 1 }; int outperm[ 2 ] = { 2, 1 }; permmap = astPermMap( 2, inperm, 2, outperm, NULL, "" ); } zoommap = astZoomMap( 2, 5.0, "" ) /* Combine them in series. */ cmpmap = astCmpMap( permmap, zoommap, 1, "" ); /* Annul the individual Mapping pointers. */ permmap = astAnnul( permmap ); zoommap = astAnnul( zoommap );
Here, the third argument (1) of the constructor function astCmpMap indicates ``in series''.
When used to transform coordinates in the forward direction, the
resulting CmpMap will apply the first component Mapping (the PermMap)
and then the second one (the ZoomMap). When transforming in the
inverse direction, it will apply the second one (in the inverse
direction) and then the first one (also in the inverse direction). In
general, although not in this particular example, the order in which
the two component Mappings are supplied is significant. Clearly, also,
the Nout attribute (number of output coordinates) for the first
Mapping must equal the Nin attribute (number of input coordinates) for
the second one.
AST A Library for Handling World Coordinate Systems in Astronomy