Grow - Built-in Operators and Functions

Similarity to C

In general, the operators and functions in our program are like in the C programming language. There are slight differences though.
Since grow's parser handle all numbers as real numbers, the operators and functions input and output paramaters are all real numbers (one can think of it as type coercion to real numbers). Examples:
  1. Boolean return values true and false are represented as 1.0 and 0.0, respectively. Boolean input values are 0.0 for false and any other value for true. Hence the binary operators operate and return these values.
  2. A power operator (^) exists (x^y == pow(x,y)).
  3. inside() and outside() boolean functions return true iff the turtle is inside or outside, respectively, the surrounding object.
  4. min() and max() accept 1 or more parameters (min(3,2,4)==2).
Here is a list of all built-in operators:

Boolean Operators

Symbol Arity Operation
|| Infix binary Boolean or
&& Infix binary Boolean and
! Unary Boolean not

Arithmetic Operators

Symbol Arity Operation
+ Infix binary or unary Plus
- Infix binary or unary Minus
* Infix binary Multiplication
/ Infix binary Division
^ Infix binary (right associative) Power

Comparison Operators

Symbol Arity Operation
< Infix binary Less than
> Infix binary Greater than
<= Infix binary Less than / equal to
>= Infix binary Greater than / equal to
== Infix binary Equal to
!= Infix binary Not equal to

Arithmetic Functions

Symbol Arity Operation
exp 1 parameter Exponent
ln 1 parameter Natural logarithm
sqr 1 parameter Square
sqrt 1 parameter Square root
min at least 1 parameter Min
max at least 1 parameter Max

Trigonometric Functions

The input to all of these functions is in radians (like in C).
Symbol Arity Operation
sin 1 parameter Sine
cos 1 parameter Cosine
tan 1 parameter Tangent
asin 1 parameter Arc sine
acos 1 parameter Arc cosine
atan 1 parameter Arc tangent

Geometric Functions

Note that inside() and outside() result is not defined for queries on the boundary of the surrounding object, or queries that are close to a boundary by more than Irit's epsilon (typical value is 1E-5). In such cases the result is deterministic but may be true for some places on the boundary and false for others. This is not a major drawback of grow, because the accuracy is not very important for the plants' topiary.
Symbol Arity Operation
inside 3 parameters Returns 1.0 if (x,y,z) is inside the surrounding object, otherwise 0.0.
outside 3 parameters The boolean not of inside.