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 ( , and ) and then use these to calculate the final results ( and ). 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 and . The intermediate variables , and (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: Expression Syntax
Up: Using MathMaps
Previous: Defining Transformation Functions

KAPPA --- Kernel Application Package