Math
Number
A decimal number that can be an integer or decimal fraction.
//!OpenSCAD
0;
Degree
A value entered in degrees.
//!OpenSCAD
0;
Basic Math
Add, subtract, multiply, divide, or use an exponent.
//!OpenSCAD
1 + 1;
1 - 1;
1 * 1;
1 / 1;
1 ^ 1;
Single Operand
Depending upon the selection, returns the square root, absolute value, negation, natural logarithm, base 10 logarithm, e to the power of, or 10 to the power of a specified number.
//!OpenSCAD
sqrt(9);
Trigonometry
Depending upon the selection returns the sine, cosine, or tangent. Argument must be in degrees and not radians. Or, returns the arcsine, arccosine, or arctangent of a number.
//!OpenSCAD
sin(45);
Common Constants
Returns one of five common constants:
- Pi - π = 3.14159
- e = 2.71828
- Phi - ϕ = 1.61803
- √2 = 1.414
- √1/2 = .707
//!OpenSCAD
3.14159,1;
Number Property
Check if a number is an even, odd, prime, whole, positive, negative, or is divisible by a certain number. Returns true or false.
//!OpenSCAD
0 % 2 == 0;
Rounding
Round a number. The drop down allows the selection of round, round up or round down
//!OpenSCAD
round(3.1);
Remainder of
Return the remainder from dividing the two numbers.
//!OpenSCAD
64 % 10;
Constrain
Constrain a number to be between the specified limits (inclusive).
//!OpenSCAD
min(max(50, 1), 100);
Random Integer
Return a random integer between the two specified limits (inclusive).
//!OpenSCAD
round(rands(1,100,1)[0]);
Random Fraction
Return a random fraction between 0.0 (inclusive) and 1.0 (exclusive).
//!OpenSCAD
rands(0,1,1)[0];