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

Linux Cross Reference
Tina4/src/vision/line2/line2_trns.c

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

  1 /**@(#)
  2 **/
  3 #include <tina/sys.h>
  4 #include <tina/sysfuncs.h>
  5 #include <tina/math.h>
  6 #include <tina/mathfuncs.h>
  7 #include <tina/vision.h>
  8 #include <tina/visionfuncs.h>
  9 
 10 void    line2_transform(Line2 * line, Transform2 trans)
 11 {
 12     if (line)
 13     {
 14         line->p1 = trans2_pos(trans, line->p1);
 15         line->p2 = trans2_pos(trans, line->p2);
 16         line->p = trans2_pos(trans, line->p);
 17         line->v = trans2_vec(trans, line->v);
 18     }
 19 }
 20 
 21 int     line2_on_and_overlap(Line2 * l1, Line2 * l2, double length_ratio, double posth)
 22 {
 23     Vec2    p1 = {Vec2_id};
 24     Vec2    p2 = {Vec2_id};
 25     float   d1, d2;
 26     float   min_length;
 27 
 28     /* find end points of l2 w.r.t. l1->p1 */
 29     p1 = vec2_diff(l2->p1, l1->p1);
 30     p2 = vec2_diff(l2->p2, l1->p1);
 31 
 32     /* and their distances from l1->p1 along direction l1->v */
 33     d1 = (float)vec2_dot(l1->v, p1);
 34     d2 = (float)vec2_dot(l1->v, p2);
 35 
 36     min_length = (float)fmin(l1->length, l2->length);
 37 
 38     if (overlap_length(d1, d2, 0.0, l1->length) < min_length * length_ratio)
 39         return (0);
 40 
 41     if (d1 > d2)
 42         SWAP(float, d1, d2);
 43 
 44     /* find distances from overlaping endpoints to other line */
 45     if (d1 < 0)                 /* use l1->p1 */
 46         p1 = vec2_projperp(vec2_diff(l1->p1, l2->p1), l2->v);
 47     else                        /* use l2->p1 */
 48         p1 = vec2_diff(p1, vec2_times(d1, l1->v));
 49 
 50     if (d2 > l1->length)        /* use l1->p2 */
 51         p2 = vec2_projperp(vec2_diff(l1->p2, l2->p1), l2->v);
 52     else                        /* use l2->p1 */
 53         p2 = vec2_diff(p2, vec2_times(d2, l1->v));
 54 
 55     posth *= posth;
 56     return (vec2_sqrmod(p1) < posth && vec2_sqrmod(p2) < posth);
 57 }
 58 
 59 int     line2_coincident(Line2 * l1, Line2 * l2, double doterror, double poserror)
 60 
 61 /* BUG */
 62 {
 63     if (l1 == NULL || l2 == NULL)
 64         return (0);
 65 
 66     return (line2_on_and_overlap(l1, l2, 0.5, poserror));
 67 }
 68 

~ [ 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.