Chapter 5 - Operators & Functions
The following operators and functions can be used in formula boxes. Examples are:
- on dialog Calculation|Configuration, tab „Evaluation Parameter“, type f(x)
- on object dialogs of sources, e.g. for input boxes „PWL“, „Transmission Loss“, and „Attenuation“,
- as a condition on dialog Modify Objects,
- in input box „Uncertainty“ on tab „General“, Configuration menu,
- in formulas for summation and for total on dialog Object-Scan etc.
| == | equals |
| != | unequal |
| >= | greater or equal |
| > | greater than |
| <= | less or equal |
| < | less than |
| ++ | energetic addition |
| -- | energetic subtraction |
| + | addition |
| - | subtraction |
| * | multiplication |
| / | division |
| ( | open bracket |
| ) | close bracket |
| max | maximum value, e.g.: max(1,2) = 2 |
| min | minimum value, e.g.: min(1,2) = 1 |
| pow | power: pow(a, b) = a^b |
| abs | absolute value or magnitude |
| log10 | logarithm to the base 10 |
| log | logarithm to the base e |
| exp10 | x-th power of 10 (10 to the x) |
| exp | x-th power of e (e to the x) |
| sqrt | square root |
| sin | sine (argument to be expressed in radians) |
| cos | cosine |
| tan | tangent |
| ctg | cotangent |
| deg2rad | conversion from degrees to radians |
| rad2deg | conversion from radians in degrees |
| arcsin | arc sine |
| arccos | arc cosine |
| arctan | arc tangent |
| iif | iif(x, a, b) returns a, if x!=0, and b if x==0 |
| rand(x,y) | generated a random number in interval between x and y |
| round(x,y) | rounds the number x to the yth decimal, for example round(1.23, 1) is rounded to 1.2. |
| floor(x) | integer of x, i.e.: floor(x.5) = x floor(-x.5) = -x-1 |
| mod(x,y) | calculates the modulo (i.e. the remainder) after division of x by y, e.g. used as condition to display just the terrain contours having integer heights HA: mod(HA,2)==0 |
| del | deletes a value with General Coordinate Transformation, e.g.: x=x keep x-coordinate y=y keep y-coordinate z=iif(z!=0, z, del) if z-coord.<>0, keep value, else delete |
| int | interpolates between values with General Coordinate Transformation, e.g.: x=x keep x-coordinate y=y keep y-coordinate z=iif(z<0.1, int, z) if z-coord.<0.1, interpolate, else keep value |
Examples
Operators & Functions
Examples for the input boxes „Attenuation“, „PWL“ and „Trans. Loss“ on the dialog of point, line, and area sources.
| Expression / Operators | |
| ((8+4+3.5+2)++17.5)-19) | chain of arithmetic operations |
| 68++65+3 = 68++(65+3) = 71 | operator + goes before operator ++ |
| SP_002++SP_005 | where SP_002 and SP_005 refer to spectra stored in the local library |
| SP_002 - 3 | 3 dB are subtracted from the current level in each frequency band of the spectrum |
| x - 55 | reduces the current number by 55 |
| x + 2 | increases the current number by 2 |
| x ++ 50 | adds 50 dB to the current level respecting rules for the addition of levels |
| x -- 50 | subtracts 50 dB from the current level respecting rules for the subtraction of levels |
| 40 ++ 40 | energetic addition (40 ++ 40 = 43) |
| 43 -- 40 | energetic subtraction (43--40 = 40) |
| 40 + 40 | arithmetic addition (40 + 40 = 80) |
| 80 - 40 | arithmetic subtraction (80 - 40 =40) |
User-definedFunctions
In CadnaA, user-defined functions may be implemented by using a DLL (dynamic-link library). Check in the CadnaA download files for the directory Support\CNA_FUNC providing an example project (CNA_FUNC) and a README .TXT file describing the interface for the DLL. In any case, an entry in the CADNAA.INI file is required for each function and the function name must be entered in a formula receiving input box of a source dialog (e.g. in the box LW_LI (for PWL) of a point source).