~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/covira/snake_run1d.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2 *
  3 * snake_run1d.c
  4 *
  5 * Snake dynamics functions using 1d mask
  6 *
  7 */
  8  
  9 #include <tina/all_tina.h>
 10 #include <tina/brain.h>
 11 #include <tina/brainfuncs.h>
 12 
 13 /*
 14 evaluate edge forces along a line at p in direction n
 15 arising from potential pot (symmetric workspace arrays
 16 line1 and line2 are supplied
 17 */
 18 static Vec2 normal_force(Vec2 p, Vec2 n, Imrect * pot,
 19                           int s, double *line1, double *line2)
 20 {
 21     int i;
 22     double f;
 23 
 24     for (i = -s; i <= s; i++)
 25     {
 26         Vec2 v = vec2_sum(p, vec2_times(i, n));
 27         line1[i] = im_sub_pixf(pot, vec2_y(v), vec2_x(v));
 28     }
 29     smask_smooth(s, line2, line1);
 30     /* smask_diff2(s, line1, line2); f = nearzeroedge(s, line1); */
 31     /* smask_diff(s, line1, line2); f = maxgradedge(s, line1); */
 32     smask_smooth(s, line2, line1);
 33     return (vec2_times(-f, n));
 34 }
 35 
 36 /*
 37 evaluate forces at snake knots in direction perp to snake
 38 */
 39 void snake_normal_forces(Snake * snake, Imrect * pot)
 40 {
 41     int i, n = snake->n, s = 10;
 42     double *line1 = tvector_alloc(-s, s + 1, double);
 43     double *line2 = tvector_alloc(-s, s + 1, double);
 44 
 45     for (i = 0; i < n; i++)
 46     {
 47         Vec2 nml = snake_perp(snake, i);
 48         snake->f[i] = normal_force(snake->p[i], nml, pot, s, line1, line2);
 49     }
 50     tvector_free(line1, -s, double);
 51     tvector_free(line2, -s, double);
 52 }
 53 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.