Fundamentals: Math

SmartCAM supports a number of built-in math operations and functions. These math functions can be used in macros and in the expression evaluator in input fields.

Math Operations

These are the basic math operators.

Operator Meaning
+ Add
- Subtract
* Multiply
/ Divide
^ Exponential

Basic Math Functions

A number of basic math functions are supported. The Operator column displays the function name, as well as the function's parameters and return value.

Operator Meaning
D=ABS(N) Absolute value
D=CEIL(N) Round-up function, CEIL of 2.3 is 3.0 and CEIL of -2.3 is -2
D=DMS(N) Converts numbers, of the form DDD.MMSS, to decimal
D=FLOOR(N) Round-down function, so FLOOR os 2.3 is 2.0 and FLOOR of -2.3 is -3
I=INT(N) Truncates the fractional portion of a decimal number and returns the integer value
D=MAX(N,N) Returns the larger of the two parameter values
D=MIN(N,N) Returns the smaller of the two parameter values
I=MOD(N,N) Returns the integer modulus of two values. If the parameters provided are decimal values, the fractional component is truncated. So MOD(9.8, 7.3) returns 2; same as MOD(9,7).
D=PI() Returns the value of PI, to eight decimal places
D=RND(D,I) Returns the value of the first decimal parameter rounded to the number of decimal positions, based on the integer second parameter. RND(3.1415, 2) returns 3.14.
I=SGN(N) Returns the sign (+/-)
Values: 1 if Positive, -1 if Negative, 0 if Zero
D=SQR(N) Square root

Trigonometric Functions

The following list of trigonometric functions are supported. The Operator column displays the function name, as well as the function's parameters and return value.

Useful Tips

All of the trigonometric functions can take a Number as the function parameter; however, it is recommended that you only use Decimal values,not Integers.

Operator Meaning Range (Min, Max)
D=SIN(N) Sine -1, 1
D=COS(N) Cosine -1, 1
D=TAN(N) Tangent Any
D=ASIN(N) Arcsine -90, 90
D=ACOS(N) Arccosine 0, 180
D=ATAN(N) Arctangent -90, 90
D=ATAN2(yval, xval) Arctangent2 -180, 180
D=ATAN2FULL(yval, xval) Arctangent2 0, 360

Order of Operations

SmartCAM uses the following math convention for order of operations:

  1. Calculation of exponentials
  2. Multiplication or division, left to right
  3. Addition or subtraction, left to right

You can control the order of operations by using parentheses. During evaluation, calculations in the innermost parentheses are handled first. For example:

If(#V6=(2 * (3.14159 * #ARAD ^ 2)))

Calculations are preformed in the following order:

  1. Raises the arc radius (#ARAD) to the second power
  2. Multiplies the resulting value by PI (3.14159)
  3. Multiplies the resulting value by 2
  4. Tests whether #V6 equals the resulting value

Related Topics

Expressions

Variables

Macro Development Fundamentals Overview

SmartCAM Automation Overview