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

Linux Cross Reference
Tina6/tina-libs/tina/geometry/geomCam_par_proj.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_par_proj.c,v $
 27  * Date    :  $Date: 2005/01/09 17:49:25 $
 28  * Version :  $Revision: 1.3 $
 29  * CVS Id  :  $Id: geomCam_par_proj.c,v 1.3 2005/01/09 17:49:25 paul Exp $
 30  *
 31  * Author  : Legacy TINA
 32  *
 33  * Notes :
 34  *
 35  * module to project from parallel camera disparity coords to word
 36  * coords and visa versa
 37  * 
 38  * f is focal length of parallel camera in pixel units I is inter-ocular
 39  * separation in units of the word coord 
 40  *
 41  *********
 42 */
 43 
 44 #include "geomCam_par_proj.h"
 45 
 46 #if HAVE_CONFIG_H
 47   #include <config.h>
 48 #endif
 49 
 50 #include <math.h>
 51 #include <tina/sys/sysDef.h>
 52 #include <tina/sys/sysPro.h>
 53 #include <tina/math/mathDef.h>
 54 #include <tina/math/mathPro.h>
 55 #include <tina/geometry/geomDef.h>
 56 #include <tina/geometry/geom_LineDef.h>
 57 #include <tina/geometry/geom_LinePro.h>
 58 #include <tina/geometry/geom_PlaneDef.h>
 59 
 60 
 61 static float f = (float)1.0, I = (float)1.0;            /* static data! */
 62 
 63 void    set_par_proj(double fnew, double Inew)
 64 {
 65     f = (float)fnew;
 66     I = (float)Inew;
 67 }
 68 
 69 void    par_proj_set(double fnew, double Inew)
 70 {
 71     f = (float)fnew;
 72     I = (float)Inew;
 73 }
 74 
 75 void    par_proj_get(float *fp, float *Ip)
 76 {
 77     *fp = f;
 78     *Ip = I;
 79 }
 80 
 81 void    par_proj_ray(Vec2 u, Vec3 * p, Vec3 * v)
 82 {
 83     *p = vec3_zero();           /* the origin of parallel coords */
 84 
 85     *v = vec3_of_vec2(u);
 86     vec3_z(*v) = f;
 87     *v = vec3_unit(*v);
 88 }
 89 
 90 Vec3    vec3_par_proj_3d(Vec3 p)
 91 {
 92     float   proj = -I / vec3_z(p);
 93 
 94     vec3_z(p) = f;
 95     return (vec3_times(proj, p));
 96 }
 97 
 98 Vec3    vec3_par_proj_disp(Vec3 p)
 99 {
100     float   proj = f / vec3_z(p);
101 
102     vec3_z(p) = -I;
103     return (vec3_times(proj, p));
104 }
105 
106 void    vec3_pp3d_inplace(Vec3 * p)
107 {
108     float   proj;
109 
110     if (p == NULL)
111         return;
112 
113     proj = -I / vec3_z(*p);
114     vec3_z(*p) = f;
115     *p = vec3_times(proj, *p);
116 }
117 
118 void    vec3_ppdisp_inplace(Vec3 * p)
119 {
120     float   proj;
121 
122     if (p == NULL)
123         return;
124 
125     proj = f / vec3_z(*p);
126     vec3_z(*p) = -I;
127     *p = vec3_times(proj, *p);
128 }
129 
130 void    line3_par_proj_3d(Line3 * line)
131 {
132     if (line == NULL)
133         return;
134 
135     line->p1 = vec3_par_proj_3d(line->p1);
136     line->p2 = vec3_par_proj_3d(line->p2);
137     line3_remake(line, THREEDIM);
138 }
139 
140 void    line3_par_proj_disp(Line3 * line)
141 {
142     if (line == NULL)
143         return;
144 
145     line->p1 = vec3_par_proj_disp(line->p1);
146     line->p2 = vec3_par_proj_disp(line->p2);
147     line3_remake((Line3 *) line, DISPARITY);
148 }
149 
150 void    plane_par_proj_3d(Plane * plane)
151 {
152     float   D;                  /* PX + QY + RZ = D disparity coords */
153     float   d;                  /* px + qy + rz = d world coords */
154     Vec3    n = {Vec3_id};
155     float   mag;
156 
157     if (plane == NULL)
158         return;
159 
160     n = plane->n;
161 
162     /* first convert plane to algerbraic form n.x = n.p */
163     D = (float)vec3_dot(plane->p, plane->n);    /* |closest approach to origin| */
164 
165     /* derive 3D algebra from disp algebra Px + Qy - Dz/f = RI */
166     d = vec3_z(n) * I;
167     vec3_z(n) = -D / f;
168 
169     mag = (float)vec3_mod(n);
170     plane->n = vec3_times(1 / mag, n);  /* make unit vector */
171     plane->p = vec3_times(d / mag, plane->n);   /* point closest to
172                                                  * origin */
173     plane->type = THREEDIM;
174 }
175 

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