Mathematical Terms (Advanced Text Capabilities)

www.CAD6.com

In any numerical entry field, such as the Coordinate Entry (F8) or the entry of a rotation angle, you can state a mathematical term instead of an explicit number. Terms consist of operands (numbers, Attributes, Variables, or constants), operators, parentheses, and functions. The usual mathematical notation is used. A term is evaluated from left to right (left-associativity).

 

In addition terms are also evaluated in texts if the corresponding Statement is used.

 

 

Operators

The following list shows the precedence of operators starting with the highest, operators in the same group (groups are separated by empty lines) have equal precedence:

 

An operand may by preceded with a single sign (unary operator):

+ or -

Sign

Examples: +8 (Result: 8), -2 (Result: -2)

 

This unary operator always yields 0 (operand not equal 0) or 1 (operand is 0) as result:

!

Logical NOT

Examples: !0 (Result: 1), !12 (Result: 0)

 

Operators in this group always yield a number as result:

^^

Power

Examples: 2^^8 (Result: 256), 100^^0.5 (Result: 10)

*

Multiplication

Examples: 3*4 (Result: 12), 2^^8*2 (Result: 512)

/

Division

Examples: 8/2 (Result: 4), 8/2*4 (Result: 16)

+

Addition

Examples: 8+2 (Result: 10), 8+2*4 (Result: 16)

-

Subtraction

Examples: 10-2 (Result: 8), 10-2/4 (Result: 9.5)

 

Operators in this group always yield 1 (true) or 0 (false) as result:

<

Less

Examples: 1<2 (Result: 1), 8<5 (Result: 0)

<=

Less or equal

Examples: 2<=2 (Result: 1), 8<=5 (Result: 0)

>

Greater

Examples: 1>0 (Result: 1), 5>8 (Result: 0)

>=

Greater or equal

Examples: 1>=1 (Result: 1), 5>=8 (Result: 0)

==

Equal

Examples: 1==1 (Result: 1), 5==8 (Result: 0)

!=

Unequal

Examples: 1!=0 (Result: 1), 5!=5 (Result: 0)

&

Bitwise AND

Example: 24&15 (Result: 8)

|

Bitwise OR

Example: 16|8 (Result: 24)

^

Bitwise XOR

Example: 24^31 (Result: 7)

 

Operators in this group always yield 1 (true) or 0 (false) as result, any operand not equal 0 is interpreted as true, 0 means false:

&&

Logical AND

Examples: 1&&!0 (Result: 1), 0&&1 (Result: 0)

||

Logical OR

Examples: 5||0 (Result: 1), 0||0 (Result: 0)

 

By using parentheses you can enforce another precedence or associativity of operators or they can be used to improve readability (it can't hurt to add a pair of parentheses):

()

Parentheses

Examples:

(8+2)*4 (Result: 40),

8/(2*4) (Result: 1),

2^^(8*2) (Result: 65536),

(0!=1)||(8<5) (Result: 1)

 

 

Functions

Arguments of functions must be always enclosed in parentheses. If a function requires two arguments then these arguments have to be separated by a semicolon. The following functions are available:

sqr

Square

Example: sqr(4) (Result: 16)

sqrt

Square root

Example: sqrt(256) (Result: 16)

ln

Logarithm with base e (natural logarithm)

Example: e^^(2*ln(10)) (Result: 100)

sin

Sinus

Example: sin(90) (Result: 1)

cos

Cosinus

Example: cos(0) (Result: 1)

tan

Tangens

Example: tan(45) (Result: 1)

arcsin

Arcussinus

Example: arcsin(1) (Result: 90)

arccos

Arcuscosinus

Example: arccos(1) (Result: 0)

arctan

Arcustangens

Example: arctan(1) (Result: 45)

ceil

Smallest whole number larger than or equal to the argument.

Examples: ceil(1.1) (Result: 2), ceil(2.4-0.5) (Result: 2)

floor

Largest whole number smaller than or equal to the argument.

Examples: floor(1.9) (Result: 1), floor(1.6+0.5) (Result: 2)

round

Nearest whole number equal to the argument.

Examples: round(1.1) (Result: 1), round(2.4-0.5) (Result: 2)

abs

Absolute value

Examples: abs(-1.1) (Result: 1.1), abs(-2) (Result: 2)

min

Minimum

Examples: min(-1;2) (Result: -1), min(1.6;2.4) (Result: 1.6)

max

Maximum

Examples: max(-1;2) (Result: 2), max(1.6;2.4) (Result: 2.4)

rand

Generates a pseudo-random number in the range 0 to argument.

Examples: rand(1) (Result: 0.6586), rand(100) (Result: 17.3681)

 

 

Attributes and Variables

In case you have defined Attributes or Variables within the active drawing, you can use those as operands as well. For that you have to enclose the attribute or variable name in ~ characters.

 

Example:

(~var1~+~var2~)/2

 

Result:

Mean value of var1 and var2.

 

 

Constants

According to the type of input being carried out, certain constants are available which can be used in the terms. They allow, for example, relative values to be entered during coordinate entry.

 

The following constants are available:

x and y

Current X- and Y-coordinates of the reference point

l

Current length of the reference object or previously entered line section

r

Current radius of the reference object

a and w

Current angle of the reference object or previously entered line section

b

Current arc length of the reference object

_fl

"Frame Left"

_fr

"Frame Right"

_ft

"Frame Top"

_fb

"Frame Bottom"

Rectangular coordinates of the frame which surrounds all currently selected objects.

_pl

"Page Left"

_pr

"Page Right"

_pt

"Page Top"

_pb

"Page Bottom"

Corner coordinates of the current page.

e

Base number for natural logarithms (2.7182...)

pi

pi (π) (3.1415...)

 

 

Units

All values entered without a specific unit relate to the current length or angle unit of the active window's coordinate system.

 

To specify a unit for a value, the appropriate abbreviation should be used. These are the possible units and their abbreviations.

µm

Micrometer = 1 / 1 000 mm

mm

Millimeter = 1 mm

cm

Centimeter = 10 mm

dm

Decimeter = 100 mm

m

Meter = 1 000 mm

km

Kilometer = 1 000 000 mm

mil

Mil = 1 / 1 000 in

in

Inch = 1 in = 25.4 mm

ft

Foot = 12 in

yd

Yard = 3 ft

ml

Mile = 1 760 yd

dp

Decipoint = 1 / 720 in

pt

Point = 1 / 72 in

bp

Didot = 1 / 2 660 m

cic

Cicero = 12 / 2 660 m

 

Possible angle units and abbreviations

deg or °

Degree = 360 per rotation

min or '

Minute = 1 / 60 degree

min or "

Second = 1 / 3600 degree

gra

Gon = 400 per rotation

rad

Radian = 2pi per rotation

rel

Relative = 1 per rotation

 

Units can be mixed within a term. These are examples using mm as the current length unit and deg as the current angle unit.

100+1in

equals 100 mm + 1 in = 125.4 mm

(100+1)in

equals 101 in = 2 565.4 mm

2yd+1ft+9,5in

equals 93.5 in = 2 374.9 mm

sin(pi rad)

equals sin(180°) = 0.0

45°60'3600"

equals 47°

 

Starting with Version 2019.1, all texts, names, variables, and attributes are Unicode-enabled. In memory, they are stored in UTF-16 format, in the CAD6 file format in UTF-8 format.

 

CAD6studio Release 2024.0 - Copyright 2024 Malz++Kassner® GmbH