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

Linux Cross Reference
Tina4/src/vision/matcher/mat_geom.c

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

  1 /**@(#)
  2 **/
  3 #include <math.h>
  4 #include <tina/sys.h>
  5 #include <tina/math.h>
  6 #include <tina/mathfuncs.h>
  7 #include <tina/vision.h>
  8 #include <tina/visionfuncs.h>
  9 
 10 static float lthres = (float) 10.0;
 11 
 12 void    matcher_set_lthres(double lengththres)
 13 {
 14     lthres = (float) lengththres;
 15 }
 16 
 17 double  matcher_get_lthres(void)
 18 {
 19     return (lthres);
 20 }
 21 
 22 void   *smm_filter(void *geom, int type)
 23 {
 24     switch (type)
 25     {
 26         case POINT3:
 27         return ((void *) point3_copy((Point3 *) geom));
 28     case LINE3:
 29         {
 30             Line3  *l = (Line3 *) geom;
 31 
 32             if (l->length > lthres)
 33                 return ((void *) line3_copy(l));
 34             return (NULL);
 35         }
 36     case CONIC3:
 37         {
 38             Conic3 *c = (Conic3 *) geom;
 39 
 40             if (c->type == ELLIPSE)
 41                 return ((void *) conic3_copy(c));
 42             return (NULL);
 43         }
 44     case PLANE:
 45         return ((void *) plane_copy((Plane *) geom));
 46     case TRANSF3:
 47         return ((void *) transf3_copy((Transf3 *) geom));
 48     }
 49     return (NULL);
 50 }
 51 
 52 Bool    smm_pwr_allowed_type(int type)
 53 {
 54     switch (type)
 55     {
 56         case POINT3:
 57         case LINE3:
 58         case CONIC3:
 59         return (true);
 60     default:
 61         return (false);
 62     }
 63 }
 64 
 65 Vec3    smm_geom_position(void *geom, int type)
 66 {
 67     switch (type)
 68     {
 69         case POINT3:
 70         return (((Point3 *) geom)->p);
 71     case LINE3:
 72         {
 73             Line3  *l = (Line3 *) geom;
 74 
 75             return (vec3_times(0.5, vec3_sum(l->p1, l->p2)));
 76         }
 77     case CONIC3:
 78         return (((Conic3 *) geom)->origin);
 79     }
 80     return (vec3(0.0, 0.0, 0.0));
 81 }
 82 
 83 double  smm_geom_separation(void *g1, int type1, void *g2, int type2)
 84 {
 85     Vec3    diff = {Vec3_id};
 86 
 87     diff = vec3_diff(smm_geom_position(g1, type1), smm_geom_position(g2, type2));
 88     return (vec3_mod(diff));
 89 }
 90 
 91 double  smm_geom_sepsq(void *g1, int type1, void *g2, int type2)
 92 {
 93     Vec3    diff = {Vec3_id};
 94 
 95     diff = vec3_diff(smm_geom_position(g1, type1), smm_geom_position(g2, type2));
 96     return (vec3_sqrmod(diff));
 97 }
 98 
 99 #define PARALLEL_DOTPROD 0.985  /* cos of 10 degrees */
100 
101 Bool    smm_geom_parallel(void *g1, int type1, void *g2, int type2)
102 {
103     switch (OPAIR(type1, type2))
104     {
105         case OPAIR(LINE3, LINE3):
106         {
107             Line3  *l1 = (Line3 *) g1;
108             Line3  *l2 = (Line3 *) g2;
109 
110             if (fabs(vec3_dot(l1->v, l2->v)) > PARALLEL_DOTPROD)
111                 return (true);
112             else
113                 return (false);
114         }
115     case OPAIR(LINE3, CONIC3):
116         {
117             Line3  *l = (Line3 *) g1;
118             Conic3 *c = (Conic3 *) g2;
119 
120             if (fabs(vec3_dot(l->v, c->ez)) > PARALLEL_DOTPROD)
121                 return (true);
122             else
123                 return (false);
124         }
125     case OPAIR(CONIC3, LINE3):
126         {
127             Conic3 *c = (Conic3 *) g1;
128             Line3  *l = (Line3 *) g2;
129 
130             if (fabs(vec3_dot(l->v, c->ez)) > PARALLEL_DOTPROD)
131                 return (true);
132             else
133                 return (false);
134         }
135     }
136     return (false);
137 }
138 

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