diff options
author | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2013-10-20 01:48:20 +0200 |
---|---|---|
committer | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2013-10-20 01:48:20 +0200 |
commit | 34f34c212da4ba62c7212b862f7a22f9c0a57615 (patch) | |
tree | b214b994ae126a9aeec03e3d8439db5fff16552a | |
parent | 34cd9df850faf0bf6b9182b3500406351ad68ae0 (diff) | |
download | linmath-34f34c212da4ba62c7212b862f7a22f9c0a57615.tar.gz linmath-34f34c212da4ba62c7212b862f7a22f9c0a57615.tar.xz linmath-34f34c212da4ba62c7212b862f7a22f9c0a57615.zip |
fixed some embarrassing syntax and semantic mistakes
-rw-r--r-- | linmath.h | 51 |
1 files changed, 20 insertions, 31 deletions
@@ -112,16 +112,28 @@ static inline void mat4x4_dup(mat4x4 M, mat4x4 N) } } } -static inline void mat4x4_col(vec4 c, mat4x4 M, int i) +static inline void mat4x4_row(vec4 r, mat4x4 M, int i) { - memcpy(c, M[i], sizeof(c)); + int k; + for(k=0; k<4; ++k) + r[k] = M[k][i]; } -static inline void mat4x4_row(vec4 r, mat4x4 M, int i) +static inline void mat4x4_col(vec4 r, mat4x4 M, int i) +{ + int k; + for(k=0; k<4; ++k) + r[k] = M[i][k]; +} +static inline void mat4x4_transpose(mat4x4 M, mat4x4 N) { - r[0] = M[0][i]; - r[1] = M[1][i]; - r[2] = M[2][i]; - r[3] = M[3][i]; + int i, j; + mat4x4 R; + for(j=0; j<4; ++j) { + for(i=0; i<4; ++i) { + R[i][j] = N[j][i]; + } + } + memcpy(M, R, sizeof(R)); } static inline void mat4x4_add(mat4x4 M, mat4x4 a, mat4x4 b) { @@ -180,7 +192,7 @@ static inline void mat4x4_translate(mat4x4 T, float x, float y, float z) } static inline void mat4x4_translate_in_place(mat4x4 M, float x, float y, float z) { - vec4 const t = {x, y, z, 1} + vec4 t = {x, y, z, 1}; vec4 r; int i; for (i = 0; i < 4; ++i) { @@ -263,29 +275,6 @@ static inline void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle) }; mat4x4_mul(Q, M, R); } -static inline void mat4x4_row(vec4 r, mat4x4 M, int i) -{ - int k; - for(k=0; k<4; ++k) - r[k] = M[k][i]; -} -static inline void mat4x4_col(vec4 r, mat4x4 M, int i) -{ - int k; - for(k=0; k<4; ++k) - r[k] = M[i][k]; -} -static inline void mat4x4_transpose(mat4x4 M, mat4x4 N) -{ - int i, j; - mat4x4 R; - for(j=0; j<4; ++j) { - for(i=0; i<4; ++i) { - R[i][j] = N[j][i]; - } - } - memcpy(M, R, sizeof(R)); -} static inline void mat4x4_invert(mat4x4 T, mat4x4 M) { mat4x4 R; |