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

Linux Cross Reference
Tina6/tina-libs/tina/geometry/geomCurve_con_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/geomCurve_con_rect.c,v $
 27  * Date    :  $Date: 2008/12/07 04:33:58 $
 28  * Version :  $Revision: 1.2 $
 29  * CVS Id  :  $Id: geomCurve_con_rect.c,v 1.2 2008/12/07 04:33:58 paul Exp $
 30  *
 31  * Author  : Legacy TINA
 32  *
 33  * Notes : projective transformation of conic
 34  *
 35  *********
 36 */
 37 
 38 #include "geomCurve_con_rect.h"
 39 
 40 #if HAVE_CONFIG_H
 41   #include <config.h>
 42 #endif
 43 
 44 
 45 #include <stdio.h>
 46 #include <math.h>
 47 #include <tina/sys/sysDef.h>
 48 #include <tina/sys/sysPro.h>
 49 #include <tina/math/mathDef.h>
 50 #include <tina/math/mathPro.h>
 51 #include <tina/geometry/geom_CurveDef.h>
 52 #include <tina/geometry/geomCurve_conic.h>
 53 #include <tina/geometry/geomCurve_con_util.h>
 54 
 55 
 56 Conic  *conic_rectify(Conic * conic, Mat3 rect)
 57 {
 58     Mat3    m = {Mat3_id};
 59     Mat3    irect = {Mat3_id};
 60     Vec2    p1 = {Vec2_id};
 61     Vec2    pmid = {Vec2_id};
 62     Vec2    p2 = {Vec2_id};
 63     Conic  *new = conic_alloc(0);
 64 
 65     irect = mat3_inverse(rect);
 66 
 67     /** transform homogeneous matrix for conic with irect **/
 68     m = mat3(conic->a, conic->b, conic->d,
 69              conic->b, conic->c, conic->e,
 70              conic->d, conic->e, conic->f);
 71     m = mat3_prod(m, irect);
 72     m = mat3_prod(mat3_transpose(irect), m);
 73     new->a = mat3_xx(m);
 74     new->b = mat3_xy(m);
 75     new->c = mat3_yy(m);
 76     new->d = mat3_xz(m);
 77     new->e = mat3_yz(m);
 78     new->f = mat3_zz(m);
 79 
 80     /** transform 3 points on conic **/
 81     p1 = conic_point(conic, conic->t1);
 82     p1 = vec2_rectify(rect, p1);
 83     pmid = conic_point(conic, 0.5 * (conic->t1 + conic->t2));
 84     pmid = vec2_rectify(rect, pmid);
 85     p2 = conic_point(conic, conic->t2);
 86     p2 = vec2_rectify(rect, p2);
 87 
 88     /** make new conic consistent **/
 89     conic_setup(new);
 90     conic_set_ends(new, p1, p2, pmid);
 91 
 92     return (new);
 93 }
 94 
 95 Conic  *conic_proj(Conic * conic, Mat3 proj)
 96 {
 97     Mat3    m = {Mat3_id};
 98     Mat3    iproj = {Mat3_id};
 99     Vec2    p1 = {Vec2_id};
100     Vec2    pmid = {Vec2_id};
101     Vec2    p2 = {Vec2_id};
102     Conic  *new = conic_alloc(0);
103 
104     iproj = mat3_inverse(proj);
105 
106     /** transform homogeneous matrix for conic with iproj **/
107     m = mat3(conic->a, conic->b, conic->d,
108              conic->b, conic->c, conic->e,
109              conic->d, conic->e, conic->f);
110     m = mat3_prod(m, iproj);
111     m = mat3_prod(mat3_transpose(iproj), m);
112     new->a = mat3_xx(m);
113     new->b = mat3_xy(m);
114     new->c = mat3_yy(m);
115     new->d = mat3_xz(m);
116     new->e = mat3_yz(m);
117     new->f = mat3_zz(m);
118 
119     /** transform 3 points on conic **/
120     p1 = conic_point(conic, conic->t1);
121     p1 = vec2_rectify(proj, p1);
122     pmid = conic_point(conic, 0.5 * (conic->t1 + conic->t2));
123     pmid = vec2_rectify(proj, pmid);
124     p2 = conic_point(conic, conic->t2);
125     p2 = vec2_rectify(proj, p2);
126 
127     /** make new conic consistent **/
128     conic_setup(new);
129     conic_set_ends(new, p1, p2, pmid);
130 
131     return (new);
132 }
133 

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