# AIFS

## Contents

## General

AIFS is a text format for representation of the iterated function systems.

Any .aifs file consists from arbitrary number of blocks (even millions).

Usually one block corresponds to one IFS

Every file starts with '@@version ..' string.

One file can include another using '@@import file_to_include.ext' directive (with relative path).

Every block starts with '@ID:ParendID', where ID and ParendID is unique identifiers of the block and its parent block.

ID can be empty if we not refer to the block from any other.

ParentID can be empty if the block has no parent.

Block can use all definitions from its parent, and can override some of them.

It is possible to call one block from another as a function by ID. In that case the first variables in the called block replaced by arguments, and the last variabale is used as return value.

## Constructions inside a block

To perform calculation with numbers and affine maps it is possible to use ordinary operations like '+', '-', '*', '/', '^' and brackets.

For numbers 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'exp', 'log', 'floor', 'ceil', 'arg' are defined.

Also 'if' function defined: if(cond, val1, val2) is equivalent to (cond>0)?val1:val2 in C-like languages.

Variable with name beginning with '$' symbol is considered as built-in variable and has special meaning.

Variable with name beginning with '&' symbol is considered as substitution and recalculated in every place where used.

**[h1,h2, .., hn]** defines vector of elements h1,h2, .., hn

Vector can be indexed by '[]' operator (from zero)

Vector with appropriate length can be automatically converted to the matrix or to the translation.

**[t1,t2, .., tn]** (when $dim=n) - translation in [math]R^n[/math]

[math]x_1,x_2,..x_n =\gt x_1+t_1, x_2+t_2, .... x_n+t_n[/math]

**[a11,a12, .., a1n, .., an1,an2, .., ann]** (when $dim=n) - linear map in [math]R^n[/math]

\begin{pmatrix} x'_1 \\ x'_2 \\ \cdots \\ x'_n \\ \end{pmatrix} = \begin{vmatrix} a_{11} & a_{12} & \cdots &a_{1n} \\ a_{21} & a_{22} & \cdots &a_{2n} \\ \cdots \\ a_{n1} & a_{n2} & \cdots &a_{nn} \\ \end{vmatrix} \begin{pmatrix} x_1 \\ x_2 \\ \cdots \\ x_n \\ \end{pmatrix}

**f1*f2*..*fn** - composition

[math]x =\gt f_1(f_2(..(f_n(x)..))[/math]

**S1 | S2 | ..| Sm** - union of the sets [math]S_1, S_2, ...S_m[/math]

**f^n=f(f(f(...)))**

composition f with itself (n times)

**f^-1**

inverse map

**$n=...**

user-defined name of the set

**$a=...**

attributes, can be c(hecked) and/or h(hidden)

**$dim=n**

if **$subspace** is not used, then dimension of the Euclidean space [math]R^n[/math] where IFS will be generated.

If **$subspace** is used then dimension of the lattice space
(for Cut and Project sets)

**$subspace=M i1 i2 ...**

Invariant subspace of the matrix M where IFS will be generated

M should be Companion matrix

i1, i2, ... - indices of the blocks from Real Jordan Form of M

Resulting subspace is a product of the subspaces that corresponds to the blocks

If omitted, then whole space (**$dim**) used.

**$companion([a0,a1,a2,..a_n-1 ])**

Companion matrix for [math]a_0+a_1*x+a_2*x^2+....a_{n-1}*x^{n-1}+x^n[/math]

**$e** - empty set

**$i** - identity map

**$semigroup([g1,g2,...gm], T)** - element of Semigroup

[math]g_1,g_2.. g_m[/math]- generators

T - [optional] **$integer** that represents length of the elements for infinite semigroups

**$vector(L, T)** - vector of numbers

L - length of the vector (0 - default = **$dim**)

T - [optional] type of the numbers (**$integer** or **$real**)

**$number(T)** - number

T - [optional] type of the number (**$integer** or **$real**)

**$real(a,b), $integer(a,b)** - type representation for real or integer numbers from a to b

**$real(v), $integer(v)** - type representation for real or integer numbers with (half-)normal distribution

abs(v) - variance

if v<0 then distribution is normal

if v>0 then distribution is half-normal

**$semigroup**, **$number**, and **$vector** can be used as templates for IFS variation (automatically, or manually in editor)

Below you can see several representations of the
Pentadentrite

Exact forms can be used for automatically searching different variations.

## Pentadentrite by affine maps

@ $n=Pentadentrite $dim=2 h0=[0,0]*[0.341063,-0.0713672,0.0713672,0.341063] h1=[0.341063,0.0713672]*[0.03752,-0.346424,0.346424,0.03752] h2=[0.378583,0.417791]*[0.341063,-0.0713672,0.0713672,0.341063] h3=[0.719646,0.489158]*[-0.233977,0.258209,-0.258209,-0.233977] h4=[0.485669,0.230949]*[0.173268,0.302316,-0.302316,0.173268] h5=[0.658937,-0.0713672]*[0.341063,-0.0713672,0.0713672,0.341063] A=h0*A|h1*A|h2*A|h3*A|h4*A|h5*A

## Pentadentrite by translations and rotations (exact, searchable)

@G $a=h $dim=4 $subspace=s 0 s=$companion([1,-1,1,-1]) g=3+s^2+s^6+s^8 h0=T h1=T h2=T h3=T h4=T h5=T &T=$semigroup([s])*$vector(0) A=g^-1*(h0|h1|h2|h3|h4|h5)*A @:G $n=Pentadentrite h0=[0,0,0,0] h1=s^2*[0,0,0,-1] h2=[1,0,1,0] h3=s^6*[-2,1,-2,2] h4=s^8*[-1,1,1,0] h5=[2,-1,1,-1]

## Pentadentrite as a curve (exact, searchable)

@G $a=h $dim=4 $subspace=s 0 s=$companion([1,-1,1,-1]) k=$vector(6,$integer(0,9)) v=[1,0,0,0] u=v*0 s0=s^k[0] s1=s^k[1] s2=s^k[2] s3=s^k[3] s4=s^k[4] s5=s^k[5] t0=1 t1=(s0*u+1)*t0 t2=(s1*u+1)*t1 t3=(s2*u+1)*t2 t4=(s3*u+1)*t3 t5=(s4*u+1)*t4 h0=t0*s0 h1=t1*s1 h2=t2*s2 h3=t3*s3 h4=t4*s4 h5=t5*s5 g=s0+s1+s2+s3+s4+s5 A=g^-1*(h0|h1|h2|h3|h4|h5)*A @:G $n=Pentadentrite k=[7,9,7,3,5,7]

## Example of user-defined functions

Blocks in the example below can be called as a function from another blocks:

v1 = scale3d(kx, ky, kz)

v2 = rotate3d([0,0,-1],90)

@scale3d kx=1 ky=1 kz=1 ret=[kx,0,0,0,ky,0,0,0,kz] @rotate3d q=[0,0,1] ang=0 k1=1 k2=1 arad=ang*asin(1)/90 sn=k2*sin(arad) cs=k2*cos(arad) qn=(q[0]*q[0]+q[1]*q[1]+q[2]*q[2])^(1/2) x=q[0]/qn y=q[1]/qn z=q[2]/qn a=[(x*x),(x*y),(x*z),(y*x),(y*y),(y*z),(z*x),(z*y),(z*z)] b=[0,z,-y,-z,0,x,y,-x,0] ret=k1*a-(b*sn)-((a-1)*cs)