Quatsch/Jux Reference

From Picogen-doc


Contents

Basics

Name Operator Example picogen-version
addition + (+ 1 2) // == 3 0.3
subtraction - (- 1 2) // == -1 0.3
multiplication * (* 1 2 3) // == 6 0.3
division / (/ 10 2 2) // == 2.5 0.3
power ^ (^ 2 2) // == 4 0.3
square root sqrt (sqrt 4) // == 2 0.3
minimum min (min 2 4 3 0.5) // == 0.5 0.3
maximum max (max 2 4 3 0.5) // == 4 0.3
linear interpolation lerp (lerp x 0 2 0) // == 0 for x=0, 2 for x==0.5, 0 for x==1 0.3
logarithm log (log x) 0.3
logarithm to base 10 log10 (log10 x) 0.3
exponential function exp (exp x) 0.3

Predicates (Comparison)

Name Operator Example Remarks picogen-version
less < (< x y 2) // == 1 when x<y and y<2, 0 otherwise 0.3
less-equal <= (<= x y 2) // == 1 when x<=y and y<=2, 0 otherwise 0.3
greater > (> x y 2) // == 1 when x>y and y>2, 0 otherwise 0.3
greater-equal >= (>= x y 2) // == 1 when x>=y and y>=2, 0 otherwise 0.3
equal = (= x y 2) // == 1 when x=y and y=2, 0 otherwise Discouraged for floating point values 0.3
not equal  != (!= x y 2) // == 1 when x<>y and y<>2, 0 otherwise Discouraged for floating point values 0.3

Range-Predicates

Name Operator Example picogen-version
inclusive range [] ([] 0 1 x) // 1 if x>=0 and x<=1, 0 otherwise 0.3
inclusive/exclusive range [[ ([[ 0 1 x) // 1 if x>=0 and x<1, 0 otherwise 0.3
exclusive range ][ (][ 0 1 x) // 1 if x>0 and x<1, 0 otherwise 0.3
exclusive/inclusive range ]] (]] 0 1 x) // 1 if x>0 and x<=1, 0 otherwise 0.3

Predicate Combiners/Mutators

Name Operator Example Remarks picogen-version
logical and and (and (< x 0) (> x -1) ) // 1 if x<0 and x>-1, 0 otherwise 0.3
logical or or (and (> x 0) (< x -1) ) // 1 if x>0 or x<-1, 0 otherwise 0.3
logical xor xor (xor (> x y) (< x -1) ) // 1 if only one of the operands is true a design lack lets this work with exactly two parameters only 0.3
logical not not (not (> x 0)) // 0 if (> x 0), 0 otherwise 0.3

Trigonometric Functions

Name Operator Example picogen-version
sine sin (sin x) 0.3
cosine cos (cos x) 0.3

Other Math Functions

Name Operator Example Remarks picogen-version
inverse inv (inv x) // == 1/x 0.3
floor floor (floor 2.5) // == 2 see also http://en.wikipedia.org/wiki/Floor_and_ceiling_functions and http://en.wikipedia.org/wiki/Floor_and_ceiling_functions#Examples 0.3
truncation trunc (trunc -7.5) // == -7 for positive numbers, this is the same as floor; see also http://en.wikipedia.org/wiki/Floor_and_ceiling_functions#Truncation and http://en.wikipedia.org/wiki/Floor_and_ceiling_functions#Examples 0.3
absolute abs (abs -7) // == 7 0.3
fractional part frac (frac 3.123) // == 0.123 see also http://en.wikipedia.org/wiki/Floor_and_ceiling_functions#Examples 0.3
negation neg (neg 4) // == -4 0.3

Control Flow

Name Operator Example Remarks picogen-version
if-then-else if (if (< x 0) 0 1) // == 0 if x<0, 1 otherwise 0.3

Configurable Functions

The configurable functions, which provide e.g. noise-, voronoi- and heightmap functions, are described here.