# HG changeset patch # User Robert McIntyre # Date 1329065798 25200 # Node ID be78d7bd6920fa73c2de4107a6a934f7443d05af # Parent 712bd7e5b148a368ce1224af4e858b3ea68e8527 fixed major bug in collapse diff -r 712bd7e5b148 -r be78d7bd6920 org/ideas.org --- a/org/ideas.org Sun Feb 12 09:05:47 2012 -0700 +++ b/org/ideas.org Sun Feb 12 09:56:38 2012 -0700 @@ -72,11 +72,12 @@ -- day - [ ] create video showing all the senses for Winston -- 2 days - [ ] send package to friends for critiques -- 2 days + - [ ] fix videos that were encoded wrong, test on InterNet Explorer. + - [ ] redo videos vision with new collapse code - [ ] write summary of project for Winston \ - [ ] project proposals for Winston \ - [ ] additional senses to be implemented for Winston | -- 2 days - [ ] send Winston package / - - [ ] fix videos that were encoded wrong, test on InterNet Explorer. ** would be cool to get done before winston - [X] enable greyscale bitmaps for touch -- 2 hours diff -r 712bd7e5b148 -r be78d7bd6920 org/sense.org --- a/org/sense.org Sun Feb 12 09:05:47 2012 -0700 +++ b/org/sense.org Sun Feb 12 09:56:38 2012 -0700 @@ -165,11 +165,13 @@ #+name: topology-2 #+begin_src clojure +(in-ns 'cortex.sense) + (defn average [coll] (/ (reduce + coll) (count coll))) -(defn collapse-1d - "One dimensional analogue of collapse." +(defn- collapse-1d + "One dimensional helper for collapse." [center line] (let [length (count line) num-above (count (filter (partial < center) line)) @@ -178,8 +180,17 @@ (+ center num-above)))) (defn collapse - "Take a set of pairs of integers and collapse them into a - contigous bitmap with no \"holes\"." + "Take a sequence of pairs of integers and collapse them into a + contigous bitmap with no \"holes\" or negative entries, as close to + the origin [0 0] as the shape permits. The order of the points is + preserved. + + eg. + (collapse [[-5 5] [5 5] --> [[0 1] [1 1] + [-5 -5] [5 -5]]) --> [0 0] [1 0]] + + (collapse [[-5 5] [-5 -5] --> [[0 1] [0 0] + [ 5 -5] [ 5 5]]) --> [1 0] [1 1]]" [points] (if (empty? points) [] (let @@ -213,8 +224,13 @@ (map (fn [[x y]] [(- x min-x) (- y min-y)]) - squeezed))] - relocated))) + squeezed)) + point-correspondance + (zipmap (sort points) (sort relocated)) + + original-order + (vec (map point-correspondance points))] + original-order))) #+end_src * Viewing Sense Data