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

Linux Cross Reference
Tina6/tina-libs/tina/geometry/geomLine_2trans.c

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

  1 /**********
  2  * 
  3  * This file is part of the TINA Open Source Image Analysis Environment
  4  * henceforth known as TINA
  5  *
  6  * TINA is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License as 
  8  * published by the Free Software Foundation.
  9  *
 10  * TINA is distributed in the hope that it will be useful,
 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  * GNU General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU General Public License
 16  * along with TINA; if not, write to the Free Software Foundation, Inc., 
 17  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  *
 19  * ANY users of TINA who require exemption from the existing licence must
 20  * negotiate a new licence with Dr. Neil.A.Thacker, the sole agent for
 21  * the University of Manchester.
 22  *
 23  **********
 24  * 
 25  * Program :    TINA
 26  * File    :  $Source: /home/tina/cvs/tina-libs/tina/geometry/geomLine_2trans.c,v $
 27  * Date    :  $Date: 2003/05/22 12:55:01 $
 28  * Version :  $Revision: 1.2 $
 29  * CVS Id  :  $Id: geomLine_2trans.c,v 1.2 2003/05/22 12:55:01 tony Exp $
 30  *
 31  * Notes :
 32  *
 33  *********
 34 */
 35 
 36 
 37 #include "geomLine_2trans.h"
 38 
 39 #if HAVE_CONFIG_H
 40   #include <config.h>
 41 #endif
 42 
 43 #include <tina/sys/sysDef.h>
 44 #include <tina/sys/sysPro.h>
 45 #include <tina/math/mathDef.h>
 46 #include <tina/math/mathPro.h>
 47 #include <tina/geometry/geom_LineDef.h>
 48 #include <tina/geometry/geom_LinePro.h>
 49 
 50 void    line2_transform(Line2 * line, Transform2 trans)
 51 {
 52     if (line)
 53     {
 54         line->p1 = trans2_pos(trans, line->p1);
 55         line->p2 = trans2_pos(trans, line->p2);
 56         line->p = trans2_pos(trans, line->p);
 57         line->v = trans2_vec(trans, line->v);
 58     }
 59 }
 60 
 61 int     line2_on_and_overlap(Line2 * l1, Line2 * l2, double length_ratio, double posth)
 62 {
 63     Vec2    p1 = {Vec2_id};
 64     Vec2    p2 = {Vec2_id};
 65     float   d1, d2;
 66     float   min_length;
 67 
 68     /* find end points of l2 w.r.t. l1->p1 */
 69     p1 = vec2_diff(l2->p1, l1->p1);
 70     p2 = vec2_diff(l2->p2, l1->p1);
 71 
 72     /* and their distances from l1->p1 along direction l1->v */
 73     d1 = (float)vec2_dot(l1->v, p1);
 74     d2 = (float)vec2_dot(l1->v, p2);
 75 
 76     min_length = (float)tina_fmin(l1->length, l2->length);
 77 
 78     if (overlap_length(d1, d2, 0.0, l1->length) < min_length * length_ratio)
 79         return (0);
 80 
 81     if (d1 > d2)
 82         SWAP(float, d1, d2);
 83 
 84     /* find distances from overlaping endpoints to other line */
 85     if (d1 < 0)                 /* use l1->p1 */
 86         p1 = vec2_projperp(vec2_diff(l1->p1, l2->p1), l2->v);
 87     else                        /* use l2->p1 */
 88         p1 = vec2_diff(p1, vec2_times(d1, l1->v));
 89 
 90     if (d2 > l1->length)        /* use l1->p2 */
 91         p2 = vec2_projperp(vec2_diff(l1->p2, l2->p1), l2->v);
 92     else                        /* use l2->p1 */
 93         p2 = vec2_diff(p2, vec2_times(d2, l1->v));
 94 
 95     posth *= posth;
 96     return (vec2_sqrmod(p1) < posth && vec2_sqrmod(p2) < posth);
 97 }
 98 
 99 int     line2_coincident(Line2 * l1, Line2 * l2, double doterror, double poserror)
100 
101 /* BUG */
102 {
103     if (l1 == NULL || l2 == NULL)
104         return (0);
105 
106     return (line2_on_and_overlap(l1, l2, 0.5, poserror));
107 }
108 

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