diff org/proprioception.org @ 175:0b9ae09eaec3

renamed functions in body
author Robert McIntyre <rlm@mit.edu>
date Sat, 04 Feb 2012 06:47:07 -0700
parents 136349ac6972
children 2902aca33c6e
line wrap: on
line diff
     1.1 --- a/org/proprioception.org	Sat Feb 04 06:29:20 2012 -0700
     1.2 +++ b/org/proprioception.org	Sat Feb 04 06:47:07 2012 -0700
     1.3 @@ -18,12 +18,6 @@
     1.4    (:import com.jme3.scene.Node)
     1.5    (:import (com.jme3.math Vector3f Quaternion)))
     1.6  
     1.7 -(defvar 
     1.8 -  ^{:arglists '([creature])}
     1.9 -  joints
    1.10 -  (sense-nodes "joints")
    1.11 -  "Return the children of the creature's \"joints\" node.")
    1.12 -
    1.13  (defn right-handed?
    1.14    "true iff the three vectors form a right handed coordinate
    1.15    system. The three vectors do not have to be normalized or
    1.16 @@ -89,6 +83,50 @@
    1.17                      (joints creature))]
    1.18      (fn []
    1.19        (map #(%) senses))))
    1.20 +
    1.21 +
    1.22 +(import java.awt.image.BufferedImage)
    1.23 +
    1.24 +(defn draw-sprite [image sprite x y color ]
    1.25 +  (dorun
    1.26 +   (for [[u v] sprite]
    1.27 +     (.setRGB image (+ u x) (+ v y) color))))
    1.28 +
    1.29 +(defn view-angle
    1.30 +  "create a debug view of an angle"
    1.31 +  [color]
    1.32 +  (let [image (BufferedImage. 50 50 BufferedImage/TYPE_INT_RGB)
    1.33 +        previous (atom [25 25])
    1.34 +        sprite [[0 0] [0 1]
    1.35 +                [0 -1] [-1 0] [1 0]]] 
    1.36 +    (fn [angle]
    1.37 +      (let [angle (float angle)]
    1.38 +        (let [position
    1.39 +              [(+ 25 (int (* 20 (Math/cos angle))))
    1.40 +               (+ 25 (int (* -20 (Math/sin angle))))]]
    1.41 +          (draw-sprite image sprite (@previous 0) (@previous 1) 0x000000)
    1.42 +          (draw-sprite image sprite (position 0) (position 1) color)
    1.43 +          (reset! previous position))
    1.44 +        image))))
    1.45 +
    1.46 +(defn proprioception-debug-window
    1.47 +  []
    1.48 +  (let [heading (view-angle 0xFF0000)
    1.49 +        pitch (view-angle 0x00FF00)
    1.50 +        roll (view-angle 0xFFFFFF)
    1.51 +        v-heading (view-image)
    1.52 +        v-pitch (view-image)
    1.53 +        v-roll (view-image)
    1.54 +        ]
    1.55 +    (fn [prop-data]
    1.56 +      (dorun
    1.57 +       (map
    1.58 +        (fn [[h p r]]
    1.59 +          (v-heading (heading h))
    1.60 +          (v-pitch (pitch p))
    1.61 +          (v-roll (roll r)))
    1.62 +        prop-data)))))
    1.63 +
    1.64  #+end_src
    1.65  
    1.66  * COMMENT generate source