OpenSCAD User Manual/Mathematical Operators

From Wikibooks, open books for an open world
Jump to: navigation, search

The text in its current form is incomplete.


[edit] Logical Operators

All logical operators take Boolean values as operands and produce a Boolean value.

&& Logical AND
|| Logical OR
! Logical NOT

[edit] Relational Operators

All relational operator take numbers as operands and produce a Boolean value. The equal and not-equal operators can also compare Boolean values.

< less than
<= less equal
== equal
!= not equal
>= greater equal
> greater than

[edit] Scalar Arithmetical Operators

The scalar arithmetical operators take numbers as operands and produce a new number.

+ add
- subtract
* multiply
/ divide
% modulo

The "-" can also be used as prefix operator to negate a number.

[edit] Vector Operators

The vector operators take vectors as operands and produce a new vector;

+ add element-wise
- subtract element-wise

The "-" can also be used as prefix operator to element-wise negate a vector.

[edit] Vector-Number Operators

The vector-number operators take a vector and a number as operands and produce a new vector;

* multiply all vector elements by number
/ divide all vector elements by number

[edit] Conditional Operators

The ?: operator can be used to conditionally evaluate one or another expression. It works like the ?: operator from the family of C-like programming languages.

Example given: x>0 ? "pos" : "neg"

Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export