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

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

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