next up previous 530
Next: Expression Syntax
Up: Using MathMaps
Previous: Defining Transformation Functions

Calculating Intermediate Values

It is sometimes useful to calculate intermediate values and then to use these in the final expressions for the output (or input) variables. This may be done by supplying additional expressions for the forward (or inverse) transformation functions. For instance, the following array of five expressions describes two-dimensional pin-cushion distortion:

         'R = SQRT( XIN $*$ XIN $+$ YIN $*$ YIN )'
         'ROUT = R $*$ ( 1 $+$ 0.1 $*$ R $*$ R )'
         'THETA = ATAN2( YIN, XIN )',
         'XOUT = ROUT $*$ COS( THETA )'
         'YOUT = ROUT $*$ SIN( THETA )'

Here, we first calculate three intermediate results ($ R$ , $ ROUT$ and $ THETA$ ) and then use these to calculate the final results ($ XOUT$ and $ YOUT$ ). The MathMap knows that only the final two results constitute values for the output variables because its Nout attribute is set to 2. You may define as many intermediate variables in this way as you choose. Having defined a variable, you may then refer to it on the right of any subsequent expressions.

Note that when defining the inverse transformation you may only refer to the output variables $ XOUT$ and $ YOUT$ . The intermediate variables $ R$ , $ ROUT$ and $ THETA$ (above) are private to the forward transformation and may not be referenced by the inverse transformation. The inverse transformation may, however, define its own private intermediate variables.


next up previous 530
Next: Expression Syntax
Up: Using MathMaps
Previous: Defining Transformation Functions

KAPPA --- Kernel Application Package
Starlink User Note 95
Malcolm J. Currie & David S. Berry
2013 February 14
E-mail:starlink@jiscmail.ac.uk

Copyright © 2013 Science and Technology Facilities Council