comparison org/touch.org @ 273:c39b8b29a79e

fixed ambigous in-text function references
author Robert McIntyre <rlm@mit.edu>
date Wed, 15 Feb 2012 06:56:47 -0700
parents e6e0bb3057b2
children 23aadf376e9d
comparison
equal deleted inserted replaced
271:5833b4ce877a 273:c39b8b29a79e
83 feeler. Then once every frame, update these positions and orientations 83 feeler. Then once every frame, update these positions and orientations
84 to match the current position and orientation of the object, and use 84 to match the current position and orientation of the object, and use
85 physics collision detection to gather tactile data. 85 physics collision detection to gather tactile data.
86 86
87 Extracting the meta-data has already been described. The third step, 87 Extracting the meta-data has already been described. The third step,
88 physics collision detection, is handled in =(touch-kernel)=. 88 physics collision detection, is handled in =touch-kernel=.
89 Translating the positions and orientations of the feelers from the 89 Translating the positions and orientations of the feelers from the
90 UV-map to world-space is itself a three-step process. 90 UV-map to world-space is itself a three-step process.
91 91
92 - Find the triangles which make up the mesh in pixel-space and in 92 - Find the triangles which make up the mesh in pixel-space and in
93 world-space. =(triangles)= =(pixel-triangles)=. 93 world-space. =triangles= =pixel-triangles=.
94 94
95 - Find the coordinates of each feeler in world-space. These are the 95 - Find the coordinates of each feeler in world-space. These are the
96 origins of the feelers. =(feeler-origins)=. 96 origins of the feelers. =feeler-origins=.
97 97
98 - Calculate the normals of the triangles in world space, and add 98 - Calculate the normals of the triangles in world space, and add
99 them to each of the origins of the feelers. These are the 99 them to each of the origins of the feelers. These are the
100 normalized coordinates of the tips of the feelers. =(feeler-tips)=. 100 normalized coordinates of the tips of the feelers. =feeler-tips=.
101 101
102 * Triangle Math 102 * Triangle Math
103 ** Schrapnel Conversion Functions 103 ** Schrapnel Conversion Functions
104 104
105 #+name: triangles-1 105 #+name: triangles-1
121 (apply #(Triangle. %1 %2 %3) (map ->vector3f points))) 121 (apply #(Triangle. %1 %2 %3) (map ->vector3f points)))
122 #+end_src 122 #+end_src
123 123
124 It is convienent to treat a =Triangle= as a vector of vectors, and a 124 It is convienent to treat a =Triangle= as a vector of vectors, and a
125 =Vector2f= or =Vector3f= as vectors of floats. (->vector3f) and 125 =Vector2f= or =Vector3f= as vectors of floats. (->vector3f) and
126 (->triangle) undo the operations of =(vector3f-seq)= and 126 (->triangle) undo the operations of =vector3f-seq= and
127 =(triangle-seq)=. If these classes implemented =Iterable= then =(seq)= 127 =triangle-seq=. If these classes implemented =Iterable= then =seq=
128 would work on them automitacally. 128 would work on them automitacally.
129 129
130 ** Decomposing a 3D shape into Triangles 130 ** Decomposing a 3D shape into Triangles
131 131
132 The rigid objects which make up a creature have an underlying 132 The rigid objects which make up a creature have an underlying
134 data involved with displaying the object. 134 data involved with displaying the object.
135 135
136 A =Mesh= is composed of =Triangles=, and each =Triangle= has three 136 A =Mesh= is composed of =Triangles=, and each =Triangle= has three
137 verticies which have coordinates in world space and UV space. 137 verticies which have coordinates in world space and UV space.
138 138
139 Here, =(triangles)= gets all the world-space triangles which compose a 139 Here, =triangles= gets all the world-space triangles which compose a
140 mesh, while =(pixel-triangles)= gets those same triangles expressed in 140 mesh, while =pixel-triangles= gets those same triangles expressed in
141 pixel coordinates (which are UV coordinates scaled to fit the height 141 pixel coordinates (which are UV coordinates scaled to fit the height
142 and width of the UV image). 142 and width of the UV image).
143 143
144 #+name: triangles-2 144 #+name: triangles-2
145 #+begin_src clojure 145 #+begin_src clojure
193 (map (partial pixel-triangle geo image) 193 (map (partial pixel-triangle geo image)
194 (range (.getTriangleCount (.getMesh geo)))))) 194 (range (.getTriangleCount (.getMesh geo))))))
195 #+end_src 195 #+end_src
196 ** The Affine Transform from one Triangle to Another 196 ** The Affine Transform from one Triangle to Another
197 197
198 =(pixel-triangles)= gives us the mesh triangles expressed in pixel 198 =pixel-triangles= gives us the mesh triangles expressed in pixel
199 coordinates and =(triangles)= gives us the mesh triangles expressed in 199 coordinates and =triangles= gives us the mesh triangles expressed in
200 world coordinates. The tactile-sensor-profile gives the position of 200 world coordinates. The tactile-sensor-profile gives the position of
201 each feeler in pixel-space. In order to convert pixel-space 201 each feeler in pixel-space. In order to convert pixel-space
202 coordinates into world-space coordinates we need something that takes 202 coordinates into world-space coordinates we need something that takes
203 coordinates on the surface of one triangle and gives the corresponding 203 coordinates on the surface of one triangle and gives the corresponding
204 coordinates on the surface of another triangle. 204 coordinates on the surface of another triangle.
261 ** Triangle Boundaries 261 ** Triangle Boundaries
262 262
263 For efficiency's sake I will divide the tactile-profile image into 263 For efficiency's sake I will divide the tactile-profile image into
264 small squares which inscribe each pixel-triangle, then extract the 264 small squares which inscribe each pixel-triangle, then extract the
265 points which lie inside the triangle and map them to 3D-space using 265 points which lie inside the triangle and map them to 3D-space using
266 =(triangle-transform)= above. To do this I need a function, 266 =triangle-transform= above. To do this I need a function,
267 =(convex-bounds)= which finds the smallest box which inscribes a 2D 267 =convex-bounds= which finds the smallest box which inscribes a 2D
268 triangle. 268 triangle.
269 269
270 =(inside-triangle?)= determines whether a point is inside a triangle 270 =inside-triangle?= determines whether a point is inside a triangle
271 in 2D pixel-space. 271 in 2D pixel-space.
272 272
273 #+name: triangles-4 273 #+name: triangles-4
274 #+begin_src clojure 274 #+begin_src clojure
275 (defn convex-bounds 275 (defn convex-bounds
367 [#^Geometry geo image] 367 [#^Geometry geo image]
368 (collapse (reduce concat (feeler-pixel-coords geo image)))) 368 (collapse (reduce concat (feeler-pixel-coords geo image))))
369 #+end_src 369 #+end_src
370 * Simulated Touch 370 * Simulated Touch
371 371
372 =(touch-kernel)= generates functions to be called from within a 372 =touch-kernel= generates functions to be called from within a
373 simulation that perform the necessary physics collisions to collect 373 simulation that perform the necessary physics collisions to collect
374 tactile data, and =(touch!)= recursively applies it to every node in 374 tactile data, and =touch!= recursively applies it to every node in
375 the creature. 375 the creature.
376 376
377 #+name: kernel 377 #+name: kernel
378 #+begin_src clojure 378 #+begin_src clojure
379 (in-ns 'cortex.touch) 379 (in-ns 'cortex.touch)