#! /bin/awk -f # # 2004 Steven Gustafson smg@cs.nott.ac.uk # # Description: awk script to generate lattice points, placing a # 1 after the x,y pair to indicate that a node is present at that location. # # Inputs: Output from list2lattice.awk program # Additionally: must make sure DEPTH is set correctly below. # Outputs: input into dfs.awk BEGIN{RS= "\n"}; BEGIN{FS= " "} { array[NR]=$1 } END{ DEPTH=10 # maximum depth of tree PI=3.14269 points=0 # number of points at this depth x=0 y=0 angle=0 # 360/points, our angle nodes=0 #calculate up to DEPTH for(depth=0;depth<=DEPTH;depth++) { points = 2 ** depth #each depth has 2^d points angle = (2*PI)/points #i is our radius for(p=1;p<=points;p=p+2) { if(!(depth==1 && p==1)) { x = depth * sin(p*(angle)); y = depth * cos(p*(angle)); if (nodes >= NR) print -x, y, "0" else print -x, y, array[++nodes] } } } }