 Timestamp:
 Feb 14, 2011, 2:26:19 AM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/matrix.h
r295 r641 176 176 GLOBALS(4) 177 177 178 template <typename T> struct Vec4x4 179 { 180 inline Vec4x4() { v[0] = v[1] = v[2] = v[3] = 0; } 181 inline Vec4x4(T val) { v[0] = v[1] = v[2] = v[3] = val; } 182 inline Vec4x4(Vec4<T> v0, Vec4<T> v1, Vec4<T> v2, Vec4<T> v3) 183 { v[0] = v0; v[1] = v1; v[2] = v2; v[3] = v3; } 184 185 inline Vec4<T>& operator[](int n) { return v[n]; } 186 inline Vec4<T> const& operator[](int n) const { return v[n]; } 187 188 inline Vec4x4<T> operator +(Vec4x4<T> const val) const 189 { 190 Vec4x4<T> ret; 191 for (int j = 0; j < 4; j++) 192 for (int i = 0; i < 4; i++) 193 ret[i][j] = v[i][j] + val[i][j]; 194 return ret; 195 } 196 197 inline Vec4x4<T> operator (Vec4x4<T> const val) const 198 { 199 Vec4x4<T> ret; 200 for (int j = 0; j < 4; j++) 201 for (int i = 0; i < 4; i++) 202 ret[i][j] = v[i][j]  val[i][j]; 203 return ret; 204 } 205 206 inline Vec4x4<T> operator *(Vec4x4<T> const val) const 207 { 208 Vec4x4<T> ret; 209 for (int j = 0; j < 4; j++) 210 for (int i = 0; i < 4; i++) 211 { 212 T tmp = 0; 213 for (int k = 0; k < 4; k++) 214 tmp += v[k][j] * val[i][k]; 215 ret[i][j] = tmp; 216 } 217 return ret; 218 } 219 220 inline Vec4<T> operator *(Vec4<T> const val) const 221 { 222 Vec4<T> ret; 223 for (int j = 0; j < 4; j++) 224 { 225 T tmp = 0; 226 for (int i = 0; i < 4; i++) 227 tmp += v[i][j] * val[i]; 228 ret[j] = tmp; 229 } 230 return ret; 231 } 232 233 Vec4<T> v[4]; 234 }; 235 236 typedef Vec4x4<float> float4x4; 237 typedef Vec4x4<int> int4x4; 238 178 239 #endif // __DH_MATRIX_H__ 179 240
Note: See TracChangeset
for help on using the changeset viewer.