Next: Unary forms, Previous: Arithmetic, Up: Arithmetic [Contents][Index]
Most two-operand binary forms have meanings dependent on the types of their arguments. An exhaustive summary of the possibilities is given in the following table.
Operator precedence is shown in this table.
Op | Precedence |
---|---|
' | highest (most tightly binding) |
^ | |
- | (unary negation) |
*
.
/ | |
+
- | |
then | lowest (least tightly binding) |
All operations are left-associative except for ‘^’. Parentheses ‘( )’ are used for grouping to override precedence in the usual way.
As you can see, the dot operator ‘.’
is usually a synonym for run-of-the-mill multiplication, ‘*’.
The meanings differ only for vector operands. The then
operator
merely reverses the operand
order with respect to normal multiplication ‘*’. The intent
here is to make compositions read more naturally. The code
(1,2,3) then scale(2) then rotate(30) then translate([1,3,0])
expresses a series of successive modifications to the point, whereas the equivalent form
translate([1,3,0]) * rotate(30) * scale(2) * (1,2,3)
will be intuitive only to mathematicians (and perhaps Arabic language readers).
Next: Unary forms, Previous: Arithmetic, Up: Arithmetic [Contents][Index]