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

Linux Cross Reference
Tina4/src/math/geom/geom.h

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

  1 #ifndef geom_HEADS_DEFINED
  2 #define geom_HEADS_DEFINED
  3 /**@(#)Matrix and vector structures in 2D and 3D
  4  */
  5 #ifndef GEOM_HEADS_DEFINED
  6 #define GEOM_HEADS_DEFINED
  7 
  8 typedef struct pos2
  9 {
 10     Ts_id ts_id;                /* Tina structure identifier */
 11     float   x;
 12     float   y;
 13 }       Pos2;
 14 #define POS2_SWAP_STRING "ff"
 15 
 16 typedef struct ipos
 17 {
 18     Ts_id ts_id;                /* Tina structure identifier */
 19     int     x;
 20     int     y;
 21 }       Ipos;
 22 #define IPOS_SWAP_STRING "ii"
 23 
 24 #define ipos_x(p) ((p).x)
 25 #define ipos_y(p) ((p).y)
 26 
 27 typedef struct pos3
 28 {
 29     Ts_id ts_id;                /* Tina structure identifier */
 30     float   x;
 31     float   y;
 32     float   z;
 33 }       Pos3;
 34 #define POS3_SWAP_STRING "fff"
 35 
 36 typedef struct vec2
 37 {
 38     Ts_id ts_id;                /* Tina structure identifier */
 39     float   el[2];
 40 }       Vec2;
 41 #define VEC2_SWAP_STRING "2[f]"
 42 
 43 #define vec2_x(v) ((v).el[0])
 44 #define vec2_y(v) ((v).el[1])
 45 #define vec2_to_ipos(_vec2) (ipos((int)  vec2_x(_vec2), (int)  vec2_y(_vec2)))
 46 #define ipos_to_vec2(_ipos) (vec2((float)ipos_x(_ipos), (float)ipos_y(_ipos)))
 47 
 48 typedef struct vec3
 49 {
 50     Ts_id ts_id;                /* Tina structure identifier */
 51     float   el[3];
 52 }       Vec3;
 53 #define VEC3_SWAP_STRING "3[f]"
 54 
 55 #define vec3_x(v) ((v).el[0])
 56 #define vec3_y(v) ((v).el[1])
 57 #define vec3_z(v) ((v).el[2])
 58 
 59 typedef struct vec4
 60 {
 61     Ts_id ts_id;                /* Tina structure identifier */
 62     float   el[4];
 63 }       Vec4;
 64 #define VEC4_SWAP_STRING "4[f]"
 65 
 66 #define vec4_x(v) ((v).el[0])
 67 #define vec4_y(v) ((v).el[1])
 68 #define vec4_z(v) ((v).el[2])
 69 #define vec4_w(v) ((v).el[3])
 70 
 71 typedef struct mat2
 72 {
 73     Ts_id ts_id;                /* Tina structure identifier */
 74     float   el[2][2];
 75 }       Mat2;
 76 #define MAT2_SWAP_STRING "4[f]"
 77 
 78 #define mat2_xx(m) ((m).el[0][0])
 79 #define mat2_xy(m) ((m).el[0][1])
 80 #define mat2_yx(m) ((m).el[1][0])
 81 #define mat2_yy(m) ((m).el[1][1])
 82 
 83 #define mat2_rowx_set(m, v) (mat2_xx(m)=vec2_x(v), mat2_xy(m)=vec2_y(v))
 84 
 85 #define mat2_rowy_set(m, v) (mat2_yx(m)=vec2_x(v), mat2_yy(m)=vec2_y(v))
 86 
 87 #define mat2_colx_set(m, v) (mat2_xx(m)=vec2_x(v), mat2_yx(m)=vec2_y(v))
 88 
 89 #define mat2_coly_set(m, v) (mat2_xy(m)=vec2_x(v), mat2_yy(m)=vec2_y(v))
 90 
 91 typedef struct mat3
 92 {
 93     Ts_id ts_id;                /* Tina structure identifier */
 94     float   el[3][3];
 95 }       Mat3;
 96 #define MAT3_SWAP_STRING "9[f]"
 97 
 98 #define mat3_xx(m) ((m).el[0][0])
 99 #define mat3_xy(m) ((m).el[0][1])
100 #define mat3_xz(m) ((m).el[0][2])
101 #define mat3_yx(m) ((m).el[1][0])
102 #define mat3_yy(m) ((m).el[1][1])
103 #define mat3_yz(m) ((m).el[1][2])
104 #define mat3_zx(m) ((m).el[2][0])
105 #define mat3_zy(m) ((m).el[2][1])
106 #define mat3_zz(m) ((m).el[2][2])
107 
108 #define mat3_rowx_set(m, v) (mat3_xx(m)=vec3_x(v), \
109                              mat3_xy(m)=vec3_y(v), \
110                              mat3_xz(m)=vec3_z(v))
111 
112 #define mat3_rowy_set(m, v) (mat3_yx(m)=vec3_x(v), \
113                              mat3_yy(m)=vec3_y(v), \
114                              mat3_yz(m)=vec3_z(v))
115 
116 #define mat3_rowz_set(m, v) (mat3_zx(m)=vec3_x(v), \
117                              mat3_zy(m)=vec3_y(v), \
118                              mat3_zz(m)=vec3_z(v))
119 
120 #define mat3_colx_set(m, v) (mat3_xx(m)=vec3_x(v), \
121                              mat3_yx(m)=vec3_y(v), \
122                              mat3_zx(m)=vec3_z(v))
123 
124 #define mat3_coly_set(m, v) (mat3_xy(m)=vec3_x(v), \
125                              mat3_yy(m)=vec3_y(v), \
126                              mat3_zy(m)=vec3_z(v))
127 
128 #define mat3_colz_set(m, v) (mat3_xz(m)=vec3_x(v), \
129                              mat3_yz(m)=vec3_y(v), \
130                              mat3_zz(m)=vec3_z(v))
131 
132 typedef struct mat4
133 {
134     Ts_id ts_id;                /* Tina structure identifier */
135     float   el[4][4];
136 }       Mat4;
137 #define MAT4_SWAP_STRING "16[f]"
138 
139 #define mat4_xx(m) ((m).el[0][0])
140 #define mat4_xy(m) ((m).el[0][1])
141 #define mat4_xz(m) ((m).el[0][2])
142 #define mat4_xw(m) ((m).el[0][3])
143 #define mat4_yx(m) ((m).el[1][0])
144 #define mat4_yy(m) ((m).el[1][1])
145 #define mat4_yz(m) ((m).el[1][2])
146 #define mat4_yw(m) ((m).el[1][3])
147 #define mat4_zx(m) ((m).el[2][0])
148 #define mat4_zy(m) ((m).el[2][1])
149 #define mat4_zz(m) ((m).el[2][2])
150 #define mat4_zw(m) ((m).el[2][3])
151 #define mat4_wx(m) ((m).el[3][0])
152 #define mat4_wy(m) ((m).el[3][1])
153 #define mat4_wz(m) ((m).el[3][2])
154 #define mat4_ww(m) ((m).el[3][3])
155 
156 #define mat4_rowx_set(m, v) (mat4_xx(m)=vec4_x(v), \
157                              mat4_xy(m)=vec4_y(v), \
158                              mat4_xz(m)=vec4_z(v), \
159                              mat4_xw(m)=vec4_w(v))
160 
161 #define mat4_rowy_set(m, v) (mat4_yx(m)=vec4_x(v), \
162                              mat4_yy(m)=vec4_y(v), \
163                              mat4_yz(m)=vec4_z(v), \
164                              mat4_yw(m)=vec4_w(v))
165 
166 #define mat4_rowz_set(m, v) (mat4_zx(m)=vec4_x(v), \
167                              mat4_zy(m)=vec4_y(v), \
168                              mat4_zz(m)=vec4_z(v), \
169                              mat4_zw(m)=vec4_w(v))
170 
171 #define mat4_roww_set(m, v) (mat4_wx(m)=vec4_x(v), \
172                              mat4_wy(m)=vec4_y(v), \
173                              mat4_wz(m)=vec4_z(v), \
174                              mat4_ww(m)=vec4_w(v))
175 
176 #define mat4_colx_set(m, v) (mat4_xx(m)=vec4_x(v), \
177                              mat4_yx(m)=vec4_y(v), \
178                              mat4_zx(m)=vec4_z(v), \
179                              mat4_wx(m)=vec4_w(v))
180 
181 #define mat4_coly_set(m, v) (mat4_xy(m)=vec4_x(v), \
182                              mat4_yy(m)=vec4_y(v), \
183                              mat4_zy(m)=vec4_z(v), \
184                              mat4_wy(m)=vec4_w(v))
185 
186 #define mat4_colz_set(m, v) (mat4_xz(m)=vec4_x(v), \
187                              mat4_yz(m)=vec4_y(v), \
188                              mat4_zz(m)=vec4_z(v), \
189                              mat4_wz(m)=vec4_w(v))
190 
191 #define mat4_colw_set(m, v) (mat4_xw(m)=vec4_x(v), \
192                              mat4_yw(m)=vec4_y(v), \
193                              mat4_zw(m)=vec4_z(v), \
194                              mat4_ww(m)=vec4_w(v))
195 #endif /*GEOM_HEADS_DEFINED*/
196 #endif /* geom_HEADS_DEFINED */
197 

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