changeset 235:be78d7bd6920

fixed major bug in collapse
author Robert McIntyre <rlm@mit.edu>
date Sun, 12 Feb 2012 09:56:38 -0700
parents 712bd7e5b148
children 3c9724c8d86b
files org/ideas.org org/sense.org
diffstat 2 files changed, 24 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/ideas.org	Sun Feb 12 09:05:47 2012 -0700
     1.2 +++ b/org/ideas.org	Sun Feb 12 09:56:38 2012 -0700
     1.3 @@ -72,11 +72,12 @@
     1.4         -- day
     1.5   - [ ] create video showing all the senses for Winston -- 2 days
     1.6   - [ ] send package to friends for critiques -- 2 days
     1.7 + - [ ] fix videos that were encoded wrong, test on InterNet Explorer.
     1.8 + - [ ] redo videos vision with new collapse code
     1.9   - [ ] write summary of project for Winston            \
    1.10   - [ ] project proposals for Winston                    \
    1.11   - [ ] additional senses to be implemented for Winston   |  -- 2 days 
    1.12   - [ ] send Winston package                             /
    1.13 - - [ ] fix videos that were encoded wrong, test on InterNet Explorer.
    1.14  
    1.15  ** would be cool to get done before winston
    1.16   - [X] enable greyscale bitmaps for touch -- 2 hours 
     2.1 --- a/org/sense.org	Sun Feb 12 09:05:47 2012 -0700
     2.2 +++ b/org/sense.org	Sun Feb 12 09:56:38 2012 -0700
     2.3 @@ -165,11 +165,13 @@
     2.4  
     2.5  #+name: topology-2
     2.6  #+begin_src clojure
     2.7 +(in-ns 'cortex.sense)
     2.8 +
     2.9  (defn average [coll]
    2.10    (/ (reduce + coll) (count coll)))
    2.11  
    2.12 -(defn collapse-1d
    2.13 -  "One dimensional analogue of collapse."
    2.14 +(defn- collapse-1d
    2.15 +  "One dimensional helper for collapse."
    2.16    [center line]
    2.17    (let [length (count line)
    2.18          num-above (count (filter (partial < center) line))
    2.19 @@ -178,8 +180,17 @@
    2.20             (+ center num-above))))
    2.21  
    2.22  (defn collapse
    2.23 -  "Take a set of pairs of integers and collapse them into a
    2.24 -   contigous bitmap with no \"holes\"."
    2.25 +  "Take a sequence of pairs of integers and collapse them into a
    2.26 +   contigous bitmap with no \"holes\" or negative entries, as close to
    2.27 +   the origin [0 0] as the shape permits. The order of the points is
    2.28 +   preserved.
    2.29 +
    2.30 +   eg.
    2.31 +   (collapse [[-5  5] [5  5]    -->  [[0 1] [1 1] 
    2.32 +              [-5 -5] [5 -5]])  -->   [0 0] [1 0]]
    2.33 +
    2.34 +   (collapse [[-5  5] [-5 -5]    -->  [[0 1] [0 0] 
    2.35 +              [ 5 -5] [ 5  5]])  -->   [1 0] [1 1]]"
    2.36    [points]
    2.37    (if (empty? points) []
    2.38        (let
    2.39 @@ -213,8 +224,13 @@
    2.40               (map (fn [[x y]]
    2.41                      [(- x min-x)
    2.42                       (- y min-y)])
    2.43 -                  squeezed))]
    2.44 -        relocated)))
    2.45 +                  squeezed))
    2.46 +           point-correspondance
    2.47 +           (zipmap  (sort points) (sort relocated))
    2.48 +
    2.49 +           original-order
    2.50 +           (vec (map point-correspondance points))]
    2.51 +        original-order)))
    2.52  #+end_src
    2.53  * Viewing Sense Data
    2.54