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

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

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

  1 /**@(#)
  2 **/
  3 #include <stdio.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 
 11 /**
 12 projective transformation of conic
 13 **/
 14 
 15 Conic  *conic_rectify(Conic * conic, Mat3 rect)
 16 {
 17     Mat3    m = {Mat3_id};
 18     Mat3    irect = {Mat3_id};
 19     Vec2    p1 = {Vec2_id};
 20     Vec2    pmid = {Vec2_id};
 21     Vec2    p2 = {Vec2_id};
 22     Conic  *new = conic_alloc((int) NULL);
 23 
 24     irect = mat3_inverse(rect);
 25 
 26     /** transform homogeneous matrix for conic with irect **/
 27     m = mat3(conic->a, conic->b, conic->d,
 28              conic->b, conic->c, conic->e,
 29              conic->d, conic->e, conic->f);
 30     m = mat3_prod(m, irect);
 31     m = mat3_prod(mat3_transpose(irect), m);
 32     new->a = mat3_xx(m);
 33     new->b = mat3_xy(m);
 34     new->c = mat3_yy(m);
 35     new->d = mat3_xz(m);
 36     new->e = mat3_yz(m);
 37     new->f = mat3_zz(m);
 38 
 39     /** transform 3 points on conic **/
 40     p1 = conic_point(conic, conic->t1);
 41     p1 = vec2_rectify(rect, p1);
 42     pmid = conic_point(conic, 0.5 * (conic->t1 + conic->t2));
 43     pmid = vec2_rectify(rect, pmid);
 44     p2 = conic_point(conic, conic->t2);
 45     p2 = vec2_rectify(rect, p2);
 46 
 47     /** make new conic consistent **/
 48     conic_setup(new);
 49     conic_set_ends(new, p1, p2, pmid);
 50 
 51     return (new);
 52 }
 53 
 54 Conic  *conic_proj(Conic * conic, Mat3 proj)
 55 {
 56     Mat3    m = {Mat3_id};
 57     Mat3    iproj = {Mat3_id};
 58     Vec2    p1 = {Vec2_id};
 59     Vec2    pmid = {Vec2_id};
 60     Vec2    p2 = {Vec2_id};
 61     Conic  *new = conic_alloc((int) NULL);
 62 
 63     iproj = mat3_inverse(proj);
 64 
 65     /** transform homogeneous matrix for conic with iproj **/
 66     m = mat3(conic->a, conic->b, conic->d,
 67              conic->b, conic->c, conic->e,
 68              conic->d, conic->e, conic->f);
 69     m = mat3_prod(m, iproj);
 70     m = mat3_prod(mat3_transpose(iproj), m);
 71     new->a = mat3_xx(m);
 72     new->b = mat3_xy(m);
 73     new->c = mat3_yy(m);
 74     new->d = mat3_xz(m);
 75     new->e = mat3_yz(m);
 76     new->f = mat3_zz(m);
 77 
 78     /** transform 3 points on conic **/
 79     p1 = conic_point(conic, conic->t1);
 80     p1 = vec2_rectify(proj, p1);
 81     pmid = conic_point(conic, 0.5 * (conic->t1 + conic->t2));
 82     pmid = vec2_rectify(proj, pmid);
 83     p2 = conic_point(conic, conic->t2);
 84     p2 = vec2_rectify(proj, p2);
 85 
 86     /** make new conic consistent **/
 87     conic_setup(new);
 88     conic_set_ends(new, p1, p2, pmid);
 89 
 90     return (new);
 91 }
 92 

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