quadtree-example.k 418 B

1234567891011121314151617181920
  1. \l quadtree.k
  2. grd:(0 0 0 0 0 0 0 0
  3. 0 0 0 0 0 0 0 0
  4. 0 0 0 0 1 1 1 0
  5. 0 0 0 0 1 1 0 0
  6. 1 1 1 1 1 1 0 0
  7. 1 1 1 1 1 1 0 0
  8. 1 1 1 1 0 0 0 0
  9. 1 1 1 1 0 0 0 1)
  10. / quadtree from grid
  11. :c:0N 4#1_qt[grd;8]
  12. drw@c
  13. / extract the nodes at indices 1 and 2 and reattach
  14. drw@ro.(am/[(,0;,1 0 2 0);;].(2 3;ex[c]'1 2))
  15. / ditto but attach to SE and NW nodes
  16. drw@ro.(am/[(,0;,0 1 2 0);;].|'(3 1;ex[c]'1 2))