QCad User Reference Manual - Mathematical Expressions

QCad User Reference Manual

# 38. Mathematical Expressions

QCad comes with a built in mathematical expression parser called 'fparser'. The parser was written by Juha Nieminen 'Warp'. Whenever there are input fields which expect a real value from the user, you can type any expression that is recognized by the parser instead. This way you always have a powerful calculator at hand.

## 38.1. Supported Constants

`pi` | 3.14159265

## 38.2. Supported Functions

The following table lists all functions supported by the expression parser. You can also find the same table in the original documentation of 'fparser'.

`abs(A)` | Absolute value of A.
`acos(A)` | Arc-cosine of A. Returns the angle, measured in degrees, whose cosine is A.
`acosh(A)` | Same as acos() but for hyperbolic cosine.
`asin(A)` | Arc-sine of A. Returns the angle, measured in degrees, whose sine is A.
`asinh(A)` | Same as asin() but for hyperbolic sine.
`atan(A)` | Arc-tangent of (A). Returns the angle, measured in degrees, whose tangent is (A).
`atan2(A,B)` | Arc-tangent of A/B. The two main differences to atan() is that it will return the right angle depending on the signs of A and B (atan() can only return values between -pi/2 and pi/2), and that the return value of pi/2 and -pi/2 are possible.
`atanh(A)` | Same as atan() but for hyperbolic tangent.
`ceil(A)` | Ceiling of A. Returns the smallest integer greater than A. Rounds up to the next higher integer.
`cos(A)` | Cosine of A. Returns the cosine of the angle A, where A is measured in degrees.
`cosh(A)` | Same as cos() but for hyperbolic cosine.
`cot(A)` | Cotangent of A (equivalent to 1/tan(A)).
`csc(A)` | Cosecant of A (equivalent to 1/sin(A)).
`eval(...)` | This is a recursive call to the function to be evaluated. The number of parameters must be the same as the number of parameters taken by the function. Usually called inside if() to avoid infinite recursion.
`exp(A)` | Exponential of A. Returns the value of e raised to the power A where e is the base of the natural logarithm, i.e. the non-repeating value approximately equal to 2.71828182846.
`floor(A)` | Floor of A. Returns the largest integer less than A. Rounds down to the next lower integer.
`if(A,B,C)` | If int(A) differs from 0, the return value of this function is B, else C. Only the parameter which needs to be evaluated is evaluated, the other parameter is skipped; this makes it safe to use eval() in them.
`int(A)` | Rounds A to the closest integer. 0.5 is rounded to 1.
`log(A)` | Natural (base e) logarithm of A.
`log10(A)` | Base 10 logarithm of A.
`max(A,B)` | If A>B, the result is A, else B.
`min(A,B)` | If A<B, the result is A, else B.
`sec(A)` | Secant of A (equivalent to 1/cos(A)).
`sin(A)` | Sine of A. Returns the sine of the angle A, where A is measured in degrees.
`sinh(A)` | Same as sin() but for hyperbolic sine.
`sqrt(A)` | Square root of A. Returns the value whose square is A.
`tan(A)` | Tangent of A. Returns the tangent of the angle A, where A is measured in degrees.
`tanh(A)` | Same as tan() but for hyperbolic tangent.