next up previous 264
Next: Combining Mappings in Parallel
Up: Compound Mappings (CmpMaps)
Previous: Compound Mappings (CmpMaps)


Combining Mappings in Series

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 ($x_1,x_2$) transform into ($5x_2,5x_1$). This can be done in two stages:

  1. Apply a PermMap ([*]) to swap the coordinate order.

  2. Apply a ZoomMap ([*]) to multiply both coordinate values by the constant 5.

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.


next up previous 264
Next: Combining Mappings in Parallel
Up: Compound Mappings (CmpMaps)
Previous: Compound Mappings (CmpMaps)

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

Copyright (C) 2009 Science \& Technology Facilities Council