# Mathematics

## Angles

Angles are interpreted in radians if they are not followed by a degree sign (`°`). You can enter `PI` or `180°` for an angle of `180°`.

> If you cannot find the degree sign on your keyboard, enter **dgn** instead. It is replaced automatically by `°`.

## Intrinsic math functions

SymbolDesigner includes a parser for mathematical functions. These functions can be used in any parameter cell in the project tree view. Parameter cells are marked with the <img src="./media/image122.png" width="16" height="16"> symbol.

Example of a formula entered by the user:

`
Sin(60°) * (10 * Geometry.Cover.Geometry.L1 / 4 - 0.025 * OperatorDiameter)
`

The formula shows the reference style used for other nodes: `Geometry.Cover.Geometry.L1` refers to the value of the `Geometry.L1` subnode of a graphical primitive named *Cover*, for example a box. The parser applies the colour and font styling automatically:

**Formula part**   **Font style:**
------------------ ----------------------
**Operators**      Upright, blue
**Numbers**        Upright, black
**Units**          Upright, bold, black
**Functions**      Upright, purple
**Variables**      Italics, black

The parser also interprets several constants:

  **Constant**            **Value**
  ----------------------- -----------
  **Pi**                  3.1415...
  **None**                0
  **Point**               1
  **Line**                2
  **Fill**                3
  **Hidden**              0
  **SimplePhysical**      1
  **DetailPhysical**      16
  **Insulation**          32
  **Operation**           64
  **Maintenance**         128
  **ReferenceGeometry**   256

> These constants are not necessarily constants in the mathematical sense. They should be used as placeholders for the appropriate values, which are filled in automatically by **3D SymbolDesigner**. For example, if in software A *None* means `0`, but in software B *None* means `-1`, **3D SymbolDesigner** replaces *None* correctly according to the export target.

The following predefined operators are available:

  **Operator**   **Operation**
  -------------- ----------------
  **+**          Addition
  **-**          Subtraction
  **\***         Multiplication
  **/**          Division
  **\\**         Integer Division
  **\^**         Power
  **(**          Left bracket
  **)**          Right bracket

The following functions are supported by the parser:

+------------------+-------------------------+-------------------------+
| **Function**     | **Function name**       | **Description**         |
+==================+=========================+=========================+
| **Abs(*x*)**     | Absolute value          | Returns the absolute    |
|                  |                         | value of *x*.           |
+------------------+-------------------------+-------------------------+
| **Cos(*x*)**     | Cosine trigonometric    |                         |
|                  | function                |                         |
+------------------+-------------------------+-------------------------+
| **Exp(*x*)**     | Exponential function    |                         |
+------------------+-------------------------+-------------------------+
| **IIf(*cond,x,y*)|                         | Returns                 |
| **               |                         | *x* if condition is     |
|                  |                         | true,                   |
|                  |                         | *y* if condition is     |
|                  |                         | false.                  |
|                  |                         | (in Visual Basic .NET)  |
+------------------+-------------------------+-------------------------+
| **Ln(*x*)**      | Natural logarithm       |                         |
+------------------+-------------------------+-------------------------+
| **Max(*x,y*)**   |                         | Compares *x* and *y*    |
|                  |                         | and returns the greater |
|                  |                         | operand.                |
+------------------+-------------------------+-------------------------+
| **Min(*x,y*)**   |                         | Compares *x* and *y*    |
|                  |                         | and returns the smaller |
|                  |                         | operand.                |
|                  |                         |                         |
|                  |                         | Please note: min        |
|                  |                         | (lowercase) is the unit |
|                  |                         | sign for minutes.       |
+------------------+-------------------------+-------------------------+
| **Now(*x*)**     |                         | Returns the date (in    |
|                  |                         | Visual Basic).          |
+------------------+-------------------------+-------------------------+
| **Rnd(*x*)**     |                         | Returns a random        |
|                  |                         | number.\                |
|                  |                         | x \<0 The same number   |
|                  |                         | every time, using *x*   |
|                  |                         | as the seed.\           |
|                  |                         | x=0 The most recently   |
|                  |                         | generated number.\      |
|                  |                         | x\>0 The next random    |
|                  |                         | number in the sequence. |
+------------------+-------------------------+-------------------------+
| **Sgn(*x*)**     | Sign function           | Returns the sign of *x*.|
+------------------+-------------------------+-------------------------+
| **Sin(*x*)**     | Sine trigonometric      | Returns the sine of *x* |
|                  | function                | (in radians).           |
+------------------+-------------------------+-------------------------+
| **Sqrt(*x*)**    | Square root             | Returns the square root |
|                  |                         | of *x*.                 |
+------------------+-------------------------+-------------------------+
| **Tan(*x*)**     | Tangent trigonometric   | Returns the tangent of  |
|                  | function                | *x*.                    |
+------------------+-------------------------+-------------------------+
| **Time**         |                         | Returns the seconds     |
|                  |                         | since midnight (in 3D   |
|                  |                         | SymbolDesigner).\       |
|                  |                         | Returns the time (in    |
|                  |                         | Visual Basic)           |
+------------------+-------------------------+-------------------------+
| **Truncate(*x*)**|                         | Returns the integer     |
|                  |                         | portion of the operand. |
+------------------+-------------------------+-------------------------+
| **Asin(*x*)**    | Inverse sine            | Asin(*x*) = Atan(*x* /  |
|                  | trigonometric function  | Sqrt (-*x* \* *x* + 1)) |
+------------------+-------------------------+-------------------------+
| **Acos(*x*)**    | Inverse cosine          | Acos(*x*) = Atan(-*x* / |
|                  | trigonometric function  | Sqrt (-*x* \* *x* + 1)) |
|                  |                         | + 2 \* Atan(1)          |
+------------------+-------------------------+-------------------------+
| **Atan(*x*)**    | Inverse tangent         |                         |
|                  | trigonometric function  |                         |
+------------------+-------------------------+-------------------------+
| **Atan2(*y,x*)** | Inverse tangent         |                         |
|                  | trigonometric function  |                         |
+------------------+-------------------------+-------------------------+

Units are defined in `Config.xls` in the `data` subdirectory of **3D SymbolDesigner**.

## Derived math functions

The following non-intrinsic mathematical functions can be derived from the intrinsic mathematical functions. These functions are not yet included in **3D SymbolDesigner**, but may be included in a future version of the software. Therefore, the names of these functions should be treated as reserved:

  **Function**         **Function name**              **Derived equivalents**
  -------------------- ------------------------------ -----------------------------------------------------------------------------------------
  **Sec(*x*)**         Secant                         Sec(*x*) = 1 / Cos(*x*)
  **CoSec(*x*)**       Cosecant                       CoSec(*x*) = 1 / Sin(*x*)
  **CoTan(*x*)**       Cotangent                      CoTan(*x*) = 1 / Tan(*x*)
  **ArcSec(*x*)**      Inverse Secant                 ArcSec(*x*) = ArcTan(*x* / Sqrt(*x* \* *x* - 1)) + Sgn((*x*) -1) \* (2 \* ArcTan(1))
  **ArcCoSec(*x*)**    Inverse Cosecant               ArcCoSec(*x*) = ArcTan(*x* / Sqrt(*x* \* *x* - 1)) + (Sgn(*x*) - 1) \* (2 \* ArcTan(1))
  **ArcCoTan(*x*)**    Inverse Cotangent              ArcCoTan(*x*) = ArcTan(*x*) + 2 \* ArcTan(1)
  **HSin(*x*)**        Hyperbolic Sine                HSin(*x*) = (Exp(*x*) - E*x*p(-*x*)) / 2
  **HCos(*x*)**        Hyperbolic Cosine              HCos(*x*) = (E*x*p(*x*) + E*x*p(-*x*)) / 2
  **HTan(*x*)**        Hyperbolic Tangent             HTan(*x*) = (E*x*p(*x*) - E*x*p(-*x*)) / (E*x*p(*x*) + E*x*p(-*x*))
  **HSec(*x*)**        Hyperbolic Secant              HSec(*x*) = 2 / (E*x*p(*x*) + E*x*p(-*x*))
  **HCoSec(*x*)**      Hyperbolic Cosecant            HCoSec(*x*) = 2 / (E*x*p(*x*) - E*x*p(-*x*))
  **HCoTan(*x*)**      Hyperbolic Cotangent           HCoTan(*x*) = (E*x*p(*x*) + E*x*p(-*x*)) / (E*x*p(*x*) - E*x*p(-*x*))
  **HArcSin(*x*)**     Inverse Hyperbolic Sine        HArcSin(*x*) = Log(*x* + Sqrt(*x* \* *x* + 1))
  **HArcCos(*x*)**     Inverse Hyperbolic Cosine      HArcCos(*x*) = Log(*x* + Sqrt(*x* \* *x* - 1))
  **HArcTan(*x*)**     Inverse Hyperbolic Tangent     HArcTan(*x*) = Log((1 + *x*) / (1 - *x*)) / 2
  **HArcSec(*x*)**     Inverse Hyperbolic Secant      HArcSec(*x*) = Log((Sqrt(-*x* \* *x* + 1) + 1) / *x*)
  **HArcCoSec(*x*)**   Inverse Hyperbolic Cosecant    HArcCoSec(*x*) = Log((Sgn(*x*) \* Sqrt(*x* \* *x* + 1) +1) / *x*)
  **HArcCoTan(*x*)**   Inverse Hyperbolic Cotangent   HArcCoTan(*x*) = Log((*x* + 1) / (*x* - 1)) / 2
                       Logarithm to base N            LogN(*x*) = Log(*x*) / Log(N)

## Naming rules

There are some basic rules for naming parameters and objects:

1.  Within the tree view, any combination of Latin characters and numbers may be used for naming parameters and objects. A parameter name must not be a number, physical unit, or reserved word, and it cannot contain `-`, `(`, `)`, `*`, `/`, `^`, `&`, or `+`. Reserved words are listed in `Config.xls` in the **ReservedWords** worksheet.

2.  Parameter mapping names must comply with the limitations of Visual Basic, for example no reserved words and no names starting with numbers, and with the limitations of the database used by SmartPlant 3D, for example name length. All parameter mapping names used must be unique.

3.  Parameter mapping names must be chosen carefully, as they are loaded into the catalogue and remain there. Ask the SmartPlant 3D catalogue administrator in your company which parameter names should be used.

4.  Variant names must be shorter than 19 characters, must not be reserved words, and must not use the value `Default` or an empty value. Variant names must be unique and must not be identical to the class name.

