Expressions
Anywhere PiQ asks for a number or a position — a point, a variable, a tool option, a line in the Interactive panel — you can type an expression instead. Points and variables defined by expressions keep them: change a variable or move a point and everything defined from it follows. Names and functions can be typed in any case.
Example drawing
The examples on these pages are worked out in a millimetre drawing with:
| Name | Is |
|---|---|
L, W |
500 and 300 |
| P0, P1, P2 | [0,0], [500,0] and [500,300]: P1 is RIGHT(P0,L), P2 is UP(P1,W) |
| P6 | [60,80] |
@5 |
A line segment from [0,0] to [100,0] |
@6 |
A circle round [50,10], radius 20 |
@7 |
A line segment from [100,0] to P6 |
Values and names
The values an expression is made of, and the names it refers to.
| Expression | What it gives |
|---|---|
| Numbers | A number: whole, decimal, a fraction, or feet and inches. |
| Strings | Text in double quotes. |
| TRUE and FALSE | The two true-or-false values. |
| Names | A variable, by its name, or a point, by its number. |
| .NAME | A property of a value by name: an element's point, a fillet's centre … |
| NAME(…) | A function of your own, defined with FUNCTION, worked out with the arguments given. |
Operators
Working with values: arithmetic, comparing, and combining TRUE and FALSE.
| Expression | What it gives |
|---|---|
| ( ) | Works out what is inside first. |
| - and ! | Minus a number or a position; the opposite of TRUE or FALSE. |
| + - * / % | Adding, subtracting, multiplying and dividing numbers and positions; remainders. |
| < <= > >= | Whether one number is less than, or more than, another. |
| == != ~= | Whether two values are equal, not equal, or as near as makes no difference. |
| && || ^ | Combines TRUE and FALSE values. |
Choosing
A value chosen by a test.
| Expression | What it gives |
|---|---|
| ? : | One value or another, depending on a test. |
| SWITCH | A value looked up in a dictionary or a list, with one for when it isn't there. |
Lists and dictionaries: several values as one, and one of them by [index] or [key]. |
|
| CONCAT, SUBRANGE, INDEXOF, CONTAINS | Lists (and strings) joined, part of one, where a value is in one, and whether it is. |
Numbers
Functions of numbers.
| Expression | What it gives |
|---|---|
| ABS | The size of a number, without its sign. |
| SIGN | Whether a number is negative, zero or positive. |
| SQR | A number squared: times itself. |
| SQRT | The square root of a number. |
| CBRT | The cube root of a number. |
| EXP | e (2.71828…) to the power of a number. |
| LOG | The natural logarithm of a number (to base e). |
| LOG10 | The logarithm of a number to base 10. |
| TRUNC | A number with its fraction cut off, towards 0. |
| ROUND | A number rounded to the nearest whole number. |
| NEARESTFRAC | A number rounded to the nearest fraction of an inch (halves, quarters … to a largest denominator). |
| FLOOR | The whole number at or below a number. |
| CEIL | The whole number at or above a number. |
| DOUBLE | A value as a decimal number. |
| INT | A number as a whole number. |
| TOMM | Inches in millimetres. |
| TOIN | Millimetres in inches. |
| MIN | The smaller of two numbers. |
| MAX | The larger of two numbers. |
| POW | A number raised to a power. |
Angles and trigonometry
The trigonometry functions work in radians; POLAR, ROTATE and the tools take degrees. DTOR and RTOD convert.
| Expression | What it gives |
|---|---|
| DTOR | Degrees in radians. |
| RTOD | Radians in degrees. |
| SIN | The sine of an angle in radians. |
| COS | The cosine of an angle in radians. |
| TAN | The tangent of an angle in radians. |
| ASIN | The angle (in radians) whose sine is a number. |
| ACOS | The angle (in radians) whose cosine is a number. |
| ATAN | The angle (in radians) whose tangent is a number. |
| SINH | The hyperbolic sine of a number. |
| COSH | The hyperbolic cosine of a number. |
| TANH | The hyperbolic tangent of a number. |
| ASINH | The inverse hyperbolic sine of a number. |
| ACOSH | The inverse hyperbolic cosine of a number. |
| ATANH | The inverse hyperbolic tangent of a number. |
| ATAN2 | The angle of a direction, from its Y and X, all the way round. |
| ANGLE | The angle of a direction (a step such as P2-P1). |
Points and directions
Positions, and points defined from other points.
| Expression | What it gives |
|---|---|
| [x,y] | A position made from an X and a Y. |
| .X and .Y | The X or the Y of a position. |
| NORMALIZE | A direction made 1 long. |
| DISTANCE | How far apart two positions are. |
| DOT | The dot product of two directions: how far one goes along the other. |
| CROSS | The cross product of two directions: which way one turns to the other. |
| LEFT, RIGHT, UP, DOWN | A point straight across or up or down from another. |
| POLAR | A point at an angle and distance from another. |
| POLARDISTANCEX | How far along an angled line from one point you go to be level with another (the same X). |
| POLARDISTANCEY | How far along an angled line from one point you go to be level with another (the same Y). |
| ALONG | A point a distance from one position towards another. |
| ALONGFROMEND | A point a distance from the second position back towards the first. |
| TRIANGULATE | The point a distance from each of two points. |
| RAYCROSSING | Where lines at an angle through two points cross. |
| LINECIRCLE | Where a line through two points crosses a circle. |
| BENDALLOWANCE | Sheet metal: the length of a bend along its neutral line. |
| BENDDEDUCTION | Sheet metal: what to take off the outside sizes for a bend. |
| KFACTOR | Sheet metal: a material's K-factor at a bend's R / T, from its K-factor table. |
| Sheet fields | What a drawing holds, for a border's title block: HOSTNOTE, DRAWINGTITLE, SHEETNO, SHEETSCALE, TODAY … |
Blending and limits
Values between others, and values kept within limits.
| Expression | What it gives |
|---|---|
| LERP | A value part of the way from one to another. |
| LERPFROMEND | A value part of the way from the second back to the first. |
| INVERSELERP | How far a value is from one to another, as a part of the way. |
| REMAP | A value moved from one range to another. |
| CLAMP | A value kept within limits. |
| SMOOTHSTEP | A smooth step from 0 to 1 as a number goes from 0 to 1. |
| SMOOTHERSTEP | An even smoother step from 0 to 1 as a number goes from 0 to 1. |
Transformations
Transformations, for moving, turning and scaling positions: a position times a transformation is the position moved.
| Expression | What it gives |
|---|---|
| TRANSLATE | A transformation that moves positions by a step. |
| ROTATE | A transformation that turns positions about a centre. |
| SCALE | A transformation that scales positions about a centre. |
| SKEW | A transformation that slants positions. |
| MATRIX | A transformation given by its six numbers (nine: a perspective). |
| IDENTITY | The transformation that changes nothing. |
| MIRROR | A transformation that mirrors positions across the line through two points. |
| INVERSE | The transformation that undoes another. |
| HOMOGRAPHY | The perspective transformation taking four or more positions to as many others. |
Points on elements
An element is written by its id, @5, and an expression can work out a position on it, so a point defined this way follows the element when it changes. The Split, Intersect, Fillet and Chamfer tools and the object snaps define their points like this rather than fixing them in space.
| Expression | What it gives |
|---|---|
| @n | An element, by its id. |
| ONELEMENT | The point a fraction of the way along an element. |
| ALONGELEMENT | The point a distance along an element. |
| FROMEND | Measures a position along an element back from its end. |
| CROSSING | Where two elements cross. |
| LENGTHOF | How long an element is, along it. |
| AREAOF | The area a closed element encloses. |
| PERIMETEROF | The length round a closed element. |
| CENTEROF | The centre of a circle, arc or ellipse. |
| QUADRANT | A quadrant point of a circle, arc or ellipse. |
| FOOT | The foot of a perpendicular from a point to an element. |
| TANGENT | Where a line from a point touches a circle or arc. |
| FILLET | The fillet arc that rounds the corner between two elements. |
| CHAMFERDISTANCES | The chamfer cutting the corner between two elements, a distance back along each. |
| CHAMFEREQUAL | The chamfer cutting the corner between two elements, the same distance back along both. |
| CHAMFERDISTANCEANGLE | The chamfer cutting the corner between two elements, a distance back along the first and leaving it at an angle. |
Laying out work on elements
The vinyl-cutting and flooring tools lay their work out on the elements of a design or a room with these, in points and blocks, so it follows the elements when they change. Elements are given by id (@5) or in lists ({@5,@6}).
| Expression | What it gives |
|---|---|
| EXTENTMIN | The lower left corner of the box round elements. |
| EXTENTMAX | The upper right corner of the box round elements. |
| WEEDLINES | Weed lines across a box, stopping at a design. |
| CONTOUR | The outline round elements' shapes, a distance out. |
| CLIPTO | The parts of elements inside a box, moved. |
| ROLLDROPS | A roll's drops across a floor. |
| ROLLSEAMS | The seams between them. |
| ROLLPLAN | The drops as cut from the roll, with their trims. |
| ROLLLENGTH | The length of roll the drops need. |
| FLOORAREA | The area of a floor's outlines joined. |