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

Linux Cross Reference
Tina5/tina-libs/tina/math/math_GeomDef.h

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

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-libs/tina/math/math_GeomDef.h,v $
 37  * Date    :  $Date: 2003/09/22 16:09:02 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: math_GeomDef.h,v 1.3 2003/09/22 16:09:02 tony Exp $
 40  *
 41  * Author  :  Legacy Tina
 42  *
 43  * Notes :Matrix and vector structures in 2D and 3D
 44  *
 45  *********
 46 */
 47 
 48 #ifndef TINA_MATH_GEOM_DEF_HDR 
 49 #define TINA_MATH_GEOM_DEF_HDR 
 50 
 51 #include <tina/sys/sysDef.h>
 52 
 53 #ifdef __cplusplus
 54 extern "C" {
 55 #endif /* __cplusplus */
 56 
 57 typedef struct pos2
 58 {
 59     Ts_id ts_id;                /* Tina structure identifier */
 60     float   x;
 61     float   y;
 62 }       Pos2;
 63 #define POS2_SWAP_STRING "ff"
 64 
 65 typedef struct ipos
 66 {
 67     Ts_id ts_id;                /* Tina structure identifier */
 68     int     x;
 69     int     y;
 70 }       Ipos;
 71 #define IPOS_SWAP_STRING "ii"
 72 
 73 #define ipos_x(p) ((p).x)
 74 #define ipos_y(p) ((p).y)
 75 
 76 typedef struct pos3
 77 {
 78     Ts_id ts_id;                /* Tina structure identifier */
 79     float   x;
 80     float   y;
 81     float   z;
 82 }       Pos3;
 83 #define POS3_SWAP_STRING "fff"
 84 
 85 typedef struct vec2
 86 {
 87     Ts_id ts_id;                /* Tina structure identifier */
 88     float   el[2];
 89 }       Vec2;
 90 #define VEC2_SWAP_STRING "2[f]"
 91 
 92 #define vec2_x(v) ((v).el[0])
 93 #define vec2_y(v) ((v).el[1])
 94 #define vec2_to_ipos(_vec2) (ipos((int)  vec2_x(_vec2), (int)  vec2_y(_vec2)))
 95 #define ipos_to_vec2(_ipos) (vec2((float)ipos_x(_ipos), (float)ipos_y(_ipos)))
 96 
 97 typedef struct vec3
 98 {
 99     Ts_id ts_id;                /* Tina structure identifier */
100     float   el[3];
101 }       Vec3;
102 #define VEC3_SWAP_STRING "3[f]"
103 
104 #define vec3_x(v) ((v).el[0])
105 #define vec3_y(v) ((v).el[1])
106 #define vec3_z(v) ((v).el[2])
107 
108 typedef struct vec4
109 {
110     Ts_id ts_id;                /* Tina structure identifier */
111     float   el[4];
112 }       Vec4;
113 #define VEC4_SWAP_STRING "4[f]"
114 
115 #define vec4_x(v) ((v).el[0])
116 #define vec4_y(v) ((v).el[1])
117 #define vec4_z(v) ((v).el[2])
118 #define vec4_w(v) ((v).el[3])
119 
120 typedef struct mat2
121 {
122     Ts_id ts_id;                /* Tina structure identifier */
123     float   el[2][2];
124 }       Mat2;
125 #define MAT2_SWAP_STRING "4[f]"
126 
127 #define mat2_xx(m) ((m).el[0][0])
128 #define mat2_xy(m) ((m).el[0][1])
129 #define mat2_yx(m) ((m).el[1][0])
130 #define mat2_yy(m) ((m).el[1][1])
131 
132 #define mat2_rowx_set(m, v) (mat2_xx(m)=vec2_x(v), mat2_xy(m)=vec2_y(v))
133 
134 #define mat2_rowy_set(m, v) (mat2_yx(m)=vec2_x(v), mat2_yy(m)=vec2_y(v))
135 
136 #define mat2_colx_set(m, v) (mat2_xx(m)=vec2_x(v), mat2_yx(m)=vec2_y(v))
137 
138 #define mat2_coly_set(m, v) (mat2_xy(m)=vec2_x(v), mat2_yy(m)=vec2_y(v))
139 
140 typedef struct mat3
141 {
142     Ts_id ts_id;                /* Tina structure identifier */
143     float   el[3][3];
144 }       Mat3;
145 #define MAT3_SWAP_STRING "9[f]"
146 
147 #define mat3_xx(m) ((m).el[0][0])
148 #define mat3_xy(m) ((m).el[0][1])
149 #define mat3_xz(m) ((m).el[0][2])
150 #define mat3_yx(m) ((m).el[1][0])
151 #define mat3_yy(m) ((m).el[1][1])
152 #define mat3_yz(m) ((m).el[1][2])
153 #define mat3_zx(m) ((m).el[2][0])
154 #define mat3_zy(m) ((m).el[2][1])
155 #define mat3_zz(m) ((m).el[2][2])
156 
157 #define mat3_rowx_set(m, v) (mat3_xx(m)=vec3_x(v), \
158                              mat3_xy(m)=vec3_y(v), \
159                              mat3_xz(m)=vec3_z(v))
160 
161 #define mat3_rowy_set(m, v) (mat3_yx(m)=vec3_x(v), \
162                              mat3_yy(m)=vec3_y(v), \
163                              mat3_yz(m)=vec3_z(v))
164 
165 #define mat3_rowz_set(m, v) (mat3_zx(m)=vec3_x(v), \
166                              mat3_zy(m)=vec3_y(v), \
167                              mat3_zz(m)=vec3_z(v))
168 
169 #define mat3_colx_set(m, v) (mat3_xx(m)=vec3_x(v), \
170                              mat3_yx(m)=vec3_y(v), \
171                              mat3_zx(m)=vec3_z(v))
172 
173 #define mat3_coly_set(m, v) (mat3_xy(m)=vec3_x(v), \
174                              mat3_yy(m)=vec3_y(v), \
175                              mat3_zy(m)=vec3_z(v))
176 
177 #define mat3_colz_set(m, v) (mat3_xz(m)=vec3_x(v), \
178                              mat3_yz(m)=vec3_y(v), \
179                              mat3_zz(m)=vec3_z(v))
180 
181 typedef struct mat4
182 {
183     Ts_id ts_id;                /* Tina structure identifier */
184     float   el[4][4];
185 }       Mat4;
186 #define MAT4_SWAP_STRING "16[f]"
187 
188 #define mat4_xx(m) ((m).el[0][0])
189 #define mat4_xy(m) ((m).el[0][1])
190 #define mat4_xz(m) ((m).el[0][2])
191 #define mat4_xw(m) ((m).el[0][3])
192 #define mat4_yx(m) ((m).el[1][0])
193 #define mat4_yy(m) ((m).el[1][1])
194 #define mat4_yz(m) ((m).el[1][2])
195 #define mat4_yw(m) ((m).el[1][3])
196 #define mat4_zx(m) ((m).el[2][0])
197 #define mat4_zy(m) ((m).el[2][1])
198 #define mat4_zz(m) ((m).el[2][2])
199 #define mat4_zw(m) ((m).el[2][3])
200 #define mat4_wx(m) ((m).el[3][0])
201 #define mat4_wy(m) ((m).el[3][1])
202 #define mat4_wz(m) ((m).el[3][2])
203 #define mat4_ww(m) ((m).el[3][3])
204 
205 #define mat4_rowx_set(m, v) (mat4_xx(m)=vec4_x(v), \
206                              mat4_xy(m)=vec4_y(v), \
207                              mat4_xz(m)=vec4_z(v), \
208                              mat4_xw(m)=vec4_w(v))
209 
210 #define mat4_rowy_set(m, v) (mat4_yx(m)=vec4_x(v), \
211                              mat4_yy(m)=vec4_y(v), \
212                              mat4_yz(m)=vec4_z(v), \
213                              mat4_yw(m)=vec4_w(v))
214 
215 #define mat4_rowz_set(m, v) (mat4_zx(m)=vec4_x(v), \
216                              mat4_zy(m)=vec4_y(v), \
217                              mat4_zz(m)=vec4_z(v), \
218                              mat4_zw(m)=vec4_w(v))
219 
220 #define mat4_roww_set(m, v) (mat4_wx(m)=vec4_x(v), \
221                              mat4_wy(m)=vec4_y(v), \
222                              mat4_wz(m)=vec4_z(v), \
223                              mat4_ww(m)=vec4_w(v))
224 
225 #define mat4_colx_set(m, v) (mat4_xx(m)=vec4_x(v), \
226                              mat4_yx(m)=vec4_y(v), \
227                              mat4_zx(m)=vec4_z(v), \
228                              mat4_wx(m)=vec4_w(v))
229 
230 #define mat4_coly_set(m, v) (mat4_xy(m)=vec4_x(v), \
231                              mat4_yy(m)=vec4_y(v), \
232                              mat4_zy(m)=vec4_z(v), \
233                              mat4_wy(m)=vec4_w(v))
234 
235 #define mat4_colz_set(m, v) (mat4_xz(m)=vec4_x(v), \
236                              mat4_yz(m)=vec4_y(v), \
237                              mat4_zz(m)=vec4_z(v), \
238                              mat4_wz(m)=vec4_w(v))
239 
240 #define mat4_colw_set(m, v) (mat4_xw(m)=vec4_x(v), \
241                              mat4_yw(m)=vec4_y(v), \
242                              mat4_zw(m)=vec4_z(v), \
243                              mat4_ww(m)=vec4_w(v))
244 
245 
246 
247 
248 #ifdef __cplusplus
249 }
250 #endif /* __cplusplus */
251 
252 #endif /* TINA_MATH_GEOM_DEF_HDR */ 
253 

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