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