From 4e59527e0813b7fb59cf981ce3c0402a3b728552 Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 26 Nov 2006 23:56:56 +0100 Subject: [PATCH] added circles-tree --- punctiform-convergence/layout.scm | 36 +++++++++++++++++++++++++++++++ xaueneuax.scm | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/punctiform-convergence/layout.scm b/punctiform-convergence/layout.scm index 551e945..b5db7b6 100644 --- a/punctiform-convergence/layout.scm +++ b/punctiform-convergence/layout.scm @@ -96,7 +96,43 @@ (shuffle-tree parent pb (random x1) (random y1))) parents))))) + ;;;;;;;;;;; ;; ; ;; ; + ;; + ;; circles-tree + ;; + ;; renders nodes on concentric circles centred on the root node. + ;; each node is given a section of the circle with which to divide + ;; between its parents. same algorithm used in fastbreeder for + ;; visualising code trees generated by genetic programming + ;; + ;;;;; ; ;; ;; ; ; + (define (circles-tree node pb x y angle-start angle-end radius) + ; loop over all parents for this node + (define (parent-loop parents n angle-per-parent) + ; calculate the section of angles for this node, and call circles-tree for it + (let ([parent-start (+ angle-start (* angle-per-parent n))]) + (circles-tree (car parents) pb x y parent-start (+ parent-start angle-per-parent) (+ radius 50))) + (if (null? (cdr parents)) + 0 + (parent-loop (cdr parents) (+ n 1) angle-per-parent))) + + ; position this in the middle of the range of angles we've been given + (send pb move node + (* (sin (+ angle-start (/ (- angle-end angle-start) 2))) radius) + (* (cos (+ angle-start (/ (- angle-end angle-start) 2))) radius)) + + ; now call parent-loop for the parents if we have any parents + (let ([parents (send node get-parents)]) + (cond + ((null? parents) + 0) + (else + (let ([angle-per-parent (/ (- angle-end angle-start) (length parents))]) + (parent-loop parents 0 angle-per-parent)))))) + + + ;;;;; ;;;;;; ;; ; ;; ; ;; ;; energy stabilisation diff --git a/xaueneuax.scm b/xaueneuax.scm index ba72d3f..e6a78e1 100644 --- a/xaueneuax.scm +++ b/xaueneuax.scm @@ -77,7 +77,7 @@ (draw-parse-tree input 1 1 node pasteboard) (eval-tree node) ;(set-node-text node (eval input)) - (wobble-tree n1 p)))) + (circles-tree n1 p 100 100 0 6.28 10)))) ;; textmode input,. . (define input (new text-field%