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

Linux Cross Reference
TINA5/tina-libs/tina/geometry/geomCam_rect.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 Lesser 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 Lesser General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU Lesser 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  **********
 20  * 
 21  * Program :    TINA
 22  * File    :  $Source: /home/tina/cvs/tina-libs/tina/geometry/geomCam_rect.c,v $
 23  * Date    :  $Date: 2005/01/09 17:49:25 $
 24  * Version :  $Revision: 1.2 $
 25  * CVS Id  :  $Id: geomCam_rect.c,v 1.2 2005/01/09 17:49:25 paul Exp $
 26  *
 27  * Author  : Legacy TINA
 28  *
 29  * Notes : general rectification function
 30  *
 31  *********
 32 */
 33 
 34 #include "geomCam_rect.h"
 35 
 36 #if HAVE_CONFIG_H
 37   #include <config.h>
 38 #endif
 39 
 40 #include <math.h>
 41 #include <tina/sys/sysDef.h>
 42 #include <tina/sys/sysPro.h>
 43 #include <tina/math/mathDef.h>
 44 #include <tina/math/mathPro.h>
 45 #include <tina/geometry/geomDef.h>
 46 #include <tina/geometry/geom_EdgeDef.h>
 47 #include <tina/geometry/geom_EdgePro.h>
 48 
 49 
 50 Vec2    rectify_pos(Mat3 rect, Vec2 p)
 51 {
 52     Vec3    w = {Vec3_id};
 53 
 54     w = proj3_of_vec2(p);
 55     w = mat3_vprod(rect, w);
 56     return (proj2_of_vec3(w));
 57 }
 58 
 59 double  rectify_orient(Mat3 rect, Vec2 p, double or)
 60 
 61 /* position */
 62 /* orientation in radians */
 63 {
 64     Vec2    md = {Vec2_id};
 65     Vec2    pd = {Vec2_id};     /* pos minus delta and plus delta */
 66     float   s = (float)sin(or), c = (float)cos(or);
 67 
 68     pd = rectify_pos(rect, vec2(vec2_x(p) + c, vec2_y(p) + s));
 69     md = rectify_pos(rect, vec2(vec2_x(p) - c, vec2_y(p) - s));
 70 
 71     p = vec2_diff(pd, md);
 72     return (atan2(vec2_y(p), vec2_x(p)));
 73 }
 74 
 75 void    rectify_pos_and_dir(Mat3 rect, Vec2 * p, Vec2 * v)
 76 
 77 /* position and direction */
 78 {
 79     Vec2    q = {Vec2_id};
 80 
 81     q = vec2_sum(*p, *v);
 82     *p = rectify_pos(rect, *p);
 83     q = rectify_pos(rect, q);
 84     *v = vec2_unit(vec2_diff(q, *p));
 85 }
 86 
 87 /* ARGSUSED quieten lint */
 88 void    edge_apply_rect(Edgel * edge, int type, Mat3 * rect)
 89 
 90 /* unused */
 91 
 92 {
 93     if (edge == NULL || rect == NULL)
 94         return;
 95 
 96     edge->type &= EDGE_SET_RECT_MASK;
 97     edge->type |= EDGE_RECTIFIED;
 98     edge->pos = rectify_pos(*rect, edge->pos);
 99     edge->orient = (float)rectify_orient(*rect, edge->pos, edge->orient);
100 }
101 
102 /* ARGSUSED quieten lint */
103 void    edge_apply_derect(Edgel * edge, int type, Mat3 * rect)
104 
105 /* unused */
106 
107 {
108     if (edge == NULL || rect == NULL)
109         return;
110 
111     edge->type &= EDGE_SET_RECT_MASK;
112     edge->type |= EDGE_NOT_RECTIFIED;
113     edge->pos = rectify_pos(*rect, edge->pos);
114     edge->orient = (float)rectify_orient(*rect, edge->pos, edge->orient);
115 }
116 
117 /* ARGSUSED quieten lint */
118 void    edge_add_rect_prop(Edgel * edge, int type, Mat3 * rect)
119 
120 /* unused */
121 
122 {
123     Vec2   *r;
124 
125     if (edge == NULL)
126         return;
127 
128     r = vec2_alloc();
129     *r = rectify_pos(*rect, edge->pos);
130     edge->props = proplist_addifnp(edge->props, (void *) r, RECTPOS, vec2_free, true);
131 }
132 
133 void    er_add_rectpos_prop(Imrect * er, Mat3 rect)
134 {
135     er_apply_to_all_edges(er, edge_add_rect_prop, (void *) &rect);
136 }
137 
138 void    er_rectify(Imrect * er, Mat3 rect)
139 {
140     er_apply_to_all_edges(er, edge_apply_rect, (void *) &rect);
141 }
142 
143 void    er_derectify(Imrect * er, Mat3 rect)
144 {
145     er_apply_to_all_edges(er, edge_apply_derect, (void *) &rect);
146 }
147 

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