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

Linux Cross Reference
Tina4/src/vision/conic/conic.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 #include <math.h>
  4 #include <tina/sys.h>
  5 #include <tina/sysfuncs.h>
  6 #include <tina/math.h>
  7 #include <tina/mathfuncs.h>
  8 #include <tina/vision.h>
  9 #include <tina/visionfuncs.h>
 10 #ifdef _PCC
 11 #include <memory.h>
 12 #endif
 13 
 14 Conic  *conic_alloc(unsigned int type)
 15 {
 16     Conic  *conic = ts_ralloc(Conic);
 17 
 18     conic->type = type;
 19     conic->label = new_label();
 20     conic->props = NULL;
 21     return (conic);
 22 }
 23 
 24 Conic  *conic_make(int type, Vec2 center, double theta, double alpha, double beta, double t1, double t2, int branch)
 25 {
 26     Conic  *conic = ts_ralloc(Conic);
 27     Mat3    rot = {Mat3_id};
 28     Mat3    con = {Mat3_id};
 29     double  cx, cy, a, b, c, s;
 30 
 31     conic->type = type;
 32     conic->label = new_label();
 33     conic->center = center;
 34     conic->theta = theta;
 35     conic->alpha = alpha;
 36     conic->beta = beta;
 37     conic->t1 = t1;
 38     conic->t2 = t2;
 39     conic->branch = branch;
 40 
 41     cx = vec2_x(center);
 42     cy = vec2_y(center);
 43     a = 1.0 / (alpha * alpha);
 44     b = 1.0 / (beta * beta);
 45     if (type == HYPERBOLA)
 46         b = -b;
 47 
 48     /** conic in own frame **/
 49     con = mat3(a, 0.0, 0.0,
 50                0.0, b, 0.0,
 51                0.0, 0.0, -1.0);
 52 
 53     /** homogeneous transform to image frame **/
 54     c = cos(theta);
 55     s = sin(theta);
 56     rot = mat3(c, s, cx,
 57                s, -c, cy,
 58                0.0, 0.0, 1.0);
 59 
 60     /** homogeneous transform from image frame **/
 61     rot = mat3_inverse(rot);
 62 
 63     /** conic in image frame **/
 64     con = mat3_prod(con, rot);
 65     con = mat3_prod(mat3_transpose(rot), con);
 66 
 67     conic->a = mat3_xx(con);
 68     conic->b = mat3_xy(con);
 69     conic->c = mat3_yy(con);
 70     conic->d = mat3_xz(con);
 71     conic->e = mat3_yz(con);
 72     conic->f = mat3_zz(con);
 73 
 74     return (conic);
 75 }
 76 
 77 Conic  *conic_copy(Conic * conic)
 78 {
 79     Conic  *copy;
 80     List   *proplist_copy();
 81 
 82     if (conic == NULL)
 83         return (NULL);
 84 
 85     copy = ts_ralloc(Conic);
 86     (void) memcpy((char *) copy, (char *) conic, sizeof(Conic));
 87     copy->props = proplist_copy(conic->props);
 88     return (copy);
 89 }
 90 
 91 /* ARGSUSED quieten lint */
 92 void   *conic_prop_get(Conic * conic, int type, int prop)
 93 {
 94     if (conic == NULL)
 95         return (NULL);
 96 
 97     return (prop_get(conic->props, prop));
 98 }
 99 
100 
101 void    conic_free(Conic * conic)
102 {
103     if (conic == NULL)
104         return;
105 
106     proplist_freelist(conic->props);
107     rfree((void *) conic);
108 }
109 

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