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

Linux Cross Reference
Tina6/tina-libs/tina/geometry/geomCurve_conic.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_conic.c,v $
 27  * Date    :  $Date: 2005/01/09 17:49:25 $
 28  * Version :  $Revision: 1.2 $
 29  * CVS Id  :  $Id: geomCurve_conic.c,v 1.2 2005/01/09 17:49:25 paul Exp $
 30  *
 31  * Author  : Legacy TINA
 32  *
 33  * Notes :
 34  *
 35  *********
 36 */
 37 
 38 #include "geomCurve_conic.h"
 39 
 40 #if HAVE_CONFIG_H
 41   #include <config.h>
 42 #endif
 43 
 44 #include <math.h>
 45 #include <string.h>
 46 #include <tina/sys/sysDef.h>
 47 #include <tina/sys/sysPro.h>
 48 #include <tina/math/mathDef.h>
 49 #include <tina/math/mathPro.h>
 50 #include <tina/geometry/geomDef.h>
 51 #include <tina/geometry/geom_CurveDef.h>
 52 #ifdef _PCC
 53 #include <memory.h>
 54 #endif
 55 
 56 Conic  *conic_alloc(unsigned int type)
 57 {
 58     Conic  *conic = ts_ralloc(Conic);
 59 
 60     conic->type = type;
 61     conic->label = new_label();
 62     conic->props = NULL;
 63     return (conic);
 64 }
 65 
 66 Conic  *conic_make(int type, Vec2 center, double theta, double alpha, double beta, double t1, double t2, int branch)
 67 {
 68     Conic  *conic = ts_ralloc(Conic);
 69     Mat3    rot = {Mat3_id};
 70     Mat3    con = {Mat3_id};
 71     double  cx, cy, a, b, c, s;
 72 
 73     conic->type = type;
 74     conic->label = new_label();
 75     conic->center = center;
 76     conic->theta = theta;
 77     conic->alpha = alpha;
 78     conic->beta = beta;
 79     conic->t1 = t1;
 80     conic->t2 = t2;
 81     conic->branch = branch;
 82 
 83     cx = vec2_x(center);
 84     cy = vec2_y(center);
 85     a = 1.0 / (alpha * alpha);
 86     b = 1.0 / (beta * beta);
 87     if (type == HYPERBOLA)
 88         b = -b;
 89 
 90     /** conic in own frame **/
 91     con = mat3(a, 0.0, 0.0,
 92                0.0, b, 0.0,
 93                0.0, 0.0, -1.0);
 94 
 95     /** homogeneous transform to image frame **/
 96     c = cos(theta);
 97     s = sin(theta);
 98     rot = mat3(c, s, cx,
 99                s, -c, cy,
100                0.0, 0.0, 1.0);
101 
102     /** homogeneous transform from image frame **/
103     rot = mat3_inverse(rot);
104 
105     /** conic in image frame **/
106     con = mat3_prod(con, rot);
107     con = mat3_prod(mat3_transpose(rot), con);
108 
109     conic->a = mat3_xx(con);
110     conic->b = mat3_xy(con);
111     conic->c = mat3_yy(con);
112     conic->d = mat3_xz(con);
113     conic->e = mat3_yz(con);
114     conic->f = mat3_zz(con);
115 
116     return (conic);
117 }
118 
119 Conic  *conic_copy(Conic * conic)
120 {
121     Conic  *copy;
122     List   *proplist_copy();
123 
124     if (conic == NULL)
125         return (NULL);
126 
127     copy = ts_ralloc(Conic);
128     (void) memcpy((char *) copy, (char *) conic, sizeof(Conic));
129     copy->props = proplist_copy(conic->props);
130     return (copy);
131 }
132 
133 /* ARGSUSED quieten lint */
134 void   *conic_prop_get(Conic * conic, int type, int prop)
135 {
136     if (conic == NULL)
137         return (NULL);
138 
139     return (prop_get(conic->props, prop));
140 }
141 
142 
143 void    conic_free(Conic * conic)
144 {
145     if (conic == NULL)
146         return;
147 
148     proplist_freelist(conic->props);
149     rfree((void *) conic);
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.