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

Linux Cross Reference
Tina4/src/vision/line3/line3_trns.c

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

  1 /**@(#)
  2 **/
  3 /* line3_trns.c
  4  * 
  5  */
  6 
  7 #include <tina/sys.h>
  8 #include <tina/sysfuncs.h>
  9 #include <tina/math.h>
 10 #include <tina/mathfuncs.h>
 11 #include <tina/vision.h>
 12 
 13 void    line3_transform(Line3 * line, Transform3 trans)
 14 {
 15     if (line == NULL)
 16         return;
 17 
 18     line->p1 = trans3_pos(trans, line->p1);
 19     line->p2 = trans3_pos(trans, line->p2);
 20     line->p = trans3_pos(trans, line->p);
 21     line->v = trans3_vec(trans, line->v);
 22 }
 23 
 24 double  overlap_length(double a1, double a2, double b1, double b2)
 25 {
 26     if (a1 > a2)
 27         SWAP(double, a1, a2);
 28     if (b1 > b2)
 29         SWAP(double, b1, b2);
 30     if (a1 > b2 || a2 < b1)
 31         return (0.0);
 32     if (a1 < b1)
 33         a1 = b1;
 34     if (a2 > b2)
 35         a2 = b2;
 36     return (a2 - a1);
 37 }
 38 
 39 int     line3_on_and_overlap(Line3 * l1, Line3 * l2, double length_ratio, double posth)
 40 {
 41     Vec3    p1 = {Vec3_id};
 42     Vec3    p2 = {Vec3_id};
 43     float   d1, d2;
 44     float   min_length;
 45 
 46     /* find end points of l2 w.r.t. l1->p1 */
 47     p1 = vec3_diff(l2->p1, l1->p1);
 48     p2 = vec3_diff(l2->p2, l1->p1);
 49 
 50     /* and their distances from l1->p1 along direction l1->v */
 51     d1 = (float) vec3_dot(l1->v, p1);
 52     d2 = (float) vec3_dot(l1->v, p2);
 53 
 54     min_length = (float) fmin(l1->length, l2->length);
 55 
 56     if (overlap_length(d1, d2, 0.0, l1->length) < min_length * length_ratio)
 57         return (0);
 58 
 59     if (d1 > d2)
 60         SWAP(float, d1, d2);
 61 
 62     /* find distances from overlaping endpoints to other line */
 63     if (d1 < 0)                 /* use l1->p1 */
 64         p1 = vec3_projperp(vec3_diff(l1->p1, l2->p1), l2->v);
 65     else                        /* use l2->p1 */
 66         p1 = vec3_diff(p1, vec3_times(d1, l1->v));
 67 
 68     if (d2 > l1->length)        /* use l1->p2 */
 69         p2 = vec3_projperp(vec3_diff(l1->p2, l2->p1), l2->v);
 70     else                        /* use l2->p1 */
 71         p2 = vec3_diff(p2, vec3_times(d2, l1->v));
 72 
 73     posth *= posth;
 74     return (vec3_sqrmod(p1) < posth && vec3_sqrmod(p2) < posth);
 75 }
 76 
 77 int     line3_coincident(Line3 * l1, Line3 * l2, double doterror, double poserror)
 78 
 79 /* BUG */
 80 {
 81     if (l1 == NULL || l2 == NULL)
 82         return (0);
 83 
 84     if (vec3_dot(l1->v, l2->v) < 0)
 85         return (0);             /* pointing in opposite directions */
 86 
 87     return (line3_on_and_overlap(l1, l2, 0.5, poserror));
 88 }
 89 
 90 Bool    line3_within_error(Line3 * l1, Line3 * l2)
 91 {
 92     Iso_error *iso1;
 93     Iso_error *iso2;
 94 
 95     if (l1 == NULL || l2 == NULL)
 96         return (false);
 97 
 98     iso1 = (Iso_error *) prop_get(l1->props, ISO_ERROR);
 99     iso2 = (Iso_error *) prop_get(l2->props, ISO_ERROR);
100 
101     if (iso1 == NULL || iso2 == NULL)
102         return (false);
103 
104     if (!line3_coincident(l1, l2, iso1->dot * iso2->dot, iso1->pos + iso2->pos))
105         return (false);
106 
107     return (true);
108 }
109 

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