similar shadows
reshaping of the shadow(two)pi layout, closer to a similar semblence, yet still in need of small furthers
This commit is contained in:
parent
f7c0baa625
commit
23ab92bdf7
3 changed files with 38 additions and 34 deletions
|
@ -41,7 +41,8 @@
|
||||||
(provide wobble-tree
|
(provide wobble-tree
|
||||||
shuffle-tree
|
shuffle-tree
|
||||||
relax-tree
|
relax-tree
|
||||||
shadowpi-tree)
|
shadowpi-tree
|
||||||
|
shadowtwopi-tree)
|
||||||
|
|
||||||
|
|
||||||
;;;;;; ; ; ;; ;;;; ;; ; ;;
|
;;;;;; ; ; ;; ;;;; ;; ; ;;
|
||||||
|
@ -184,48 +185,50 @@
|
||||||
;; for interactive graph visualization and animation" by Andrew Pavlo,
|
;; for interactive graph visualization and animation" by Andrew Pavlo,
|
||||||
;; Christopher Homan & Jonathan Schull
|
;; Christopher Homan & Jonathan Schull
|
||||||
;;
|
;;
|
||||||
;; - since each node may have any number of parents, yet only a single child,
|
|
||||||
;; thi sinterpretation of the algorithm is essentially the same, if 'children'
|
|
||||||
;; is read as 'parents'
|
|
||||||
;;
|
|
||||||
;;;;; ; ;;; ; ;
|
;;;;; ; ;;; ; ;
|
||||||
|
|
||||||
(define twopi (* 2 pi))
|
(define twopi (* 2 pi))
|
||||||
|
|
||||||
|
(define (shadowpi-tree node pb theta r)
|
||||||
(define (shadowpi-tree node pb x y t1 t2 r)
|
;; given a node from which to draw the layout, angle theta, radius, r
|
||||||
;; node from whcih to draw the layout, centred at x,y on the containment arc
|
|
||||||
;; given by t1->t2 with radius, r
|
|
||||||
(let* ([parents (send node get-parents)]
|
(let* ([parents (send node get-parents)]
|
||||||
[n (length parents)]
|
[e (length parents)]
|
||||||
[xi (snip-x node)]
|
[xi (snip-x node)]
|
||||||
[yi (snip-y node)]
|
[yi (snip-y node)]
|
||||||
(phi 0.75))
|
(b (/ pi (if (eq? e 0) 1 e)))
|
||||||
|
(a (- (+ theta (/ pi 2)) (/ b 2)))
|
||||||
|
(r1 (* 2 r (sin (/ b 2)))))
|
||||||
|
|
||||||
;; distribute parents of given node evenly along a containment circle
|
;; distribute parents of given node evenly along a containment circle
|
||||||
;; centered on the node.
|
;; centered on the node.
|
||||||
|
(for-each (lambda (parent)
|
||||||
(dotimes (k n)
|
(let ((x1 (+ xi (* r (cos a))))
|
||||||
(let ((parent (list-ref parents k))
|
(y1 (+ yi (* r (sin a)))))
|
||||||
(x1 (* r (cos (* (+ t1 (- t2 t1)) (/ k n)))))
|
(send pb move-to parent x1 y1)
|
||||||
(y1 (* r (sin (* (+ t1 (- t2 t1)) (/ k n))))))
|
(shadowpi-tree parent pb a r1)
|
||||||
(send pb move-to parent
|
(set! a (- a b))))
|
||||||
(+ xi x1) (+ yi y1))
|
parents)))
|
||||||
|
|
||||||
;; draw circles around the node’s parents and evenly distribute their
|
|
||||||
;; parents along containment arcs.
|
|
||||||
|
|
||||||
(shadowpi-tree parent pb
|
|
||||||
(+ xi x1) (+ yi y1) ;; centred on
|
(define (shadowtwopi-tree node pb theta r)
|
||||||
|
;; given a node from which to draw the layout, angle theta, radius, r
|
||||||
(- (atan (/ (- yi (+ yi y1)) (- xi (+ xi x1)))) (/ pi 2))
|
(let* ([parents (send node get-parents)]
|
||||||
(+ (/ pi n) (atan (/ (- yi y1) (- xi x1))))
|
[e (length parents)]
|
||||||
|
[xi (snip-x node)]
|
||||||
(* r phi)) ;; radius
|
[yi (snip-y node)]
|
||||||
|
(b (/ twopi (if (eq? e 0) 1 e)))
|
||||||
;; this proceeds recursively, so that successively distant descendants of
|
(a (- (+ theta (/ pi 2)) (/ b 2)))
|
||||||
;; the goven node are positioned on successively smaller containment arcs.
|
(r1 (* 2 r (sin (/ b 2)))))
|
||||||
|
|
||||||
|
;; distribute parents of given node evenly along a containment circle
|
||||||
|
;; centered on the node.
|
||||||
|
(for-each (lambda (parent)
|
||||||
|
(let ((x1 (+ xi (* r (cos a))))
|
||||||
|
(y1 (+ yi (* r (sin a)))))
|
||||||
|
(send pb move-to parent x1 y1)
|
||||||
|
(shadowpi-tree parent pb a r1)
|
||||||
|
(set! a (- a b))))
|
||||||
|
parents)))
|
||||||
|
|
||||||
))))
|
|
||||||
|
|
||||||
) ;; end of module
|
) ;; end of module
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
relax-tree
|
relax-tree
|
||||||
eval-tree
|
eval-tree
|
||||||
shadowpi-tree
|
shadowpi-tree
|
||||||
|
shadowtwopi-tree
|
||||||
|
|
||||||
tree->sexp
|
tree->sexp
|
||||||
to-string
|
to-string
|
||||||
|
|
|
@ -118,7 +118,7 @@
|
||||||
[(#\z) ;; C-z re.colour
|
[(#\z) ;; C-z re.colour
|
||||||
(colour-tree selected-snip p)]
|
(colour-tree selected-snip p)]
|
||||||
[(#\l) ;; C-x re.lapse
|
[(#\l) ;; C-x re.lapse
|
||||||
(shadowpi-tree selected-snip p 10 10 0 (* 2 pi) 120)]
|
(shadowtwopi-tree selected-snip p 0 80)]
|
||||||
[(#\=) ;; C-= zoom->out
|
[(#\=) ;; C-= zoom->out
|
||||||
(send p zoom 1.1)]
|
(send p zoom 1.1)]
|
||||||
[(#\-) ;; C-- zoom->in
|
[(#\-) ;; C-- zoom->in
|
||||||
|
|
Loading…
Reference in a new issue