aboutsummaryrefslogtreecommitdiffstats
path: root/linmath.h
diff options
context:
space:
mode:
authorWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2012-09-30 09:45:43 +0200
committerWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2012-09-30 09:45:43 +0200
commite094d971276d6959662de186fe82ca1876d0d88a (patch)
treec7238ab24d4910b483cfae9e30f6602710c3dd95 /linmath.h
parentc397aa544cc8f9e45b5e28b9d03c46c2b308d54f (diff)
downloadlinmath-e094d971276d6959662de186fe82ca1876d0d88a.tar.gz
linmath-e094d971276d6959662de186fe82ca1876d0d88a.tar.xz
linmath-e094d971276d6959662de186fe82ca1876d0d88a.zip
fixed several bugs in matrix processing
Diffstat (limited to 'linmath.h')
-rw-r--r--linmath.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/linmath.h b/linmath.h
index 7207dd7..6c06269 100644
--- a/linmath.h
+++ b/linmath.h
@@ -124,12 +124,18 @@ static inline void mat4x4_sub(mat4x4 M, mat4x4 a, mat4x4 b)
for(i=0; i<4; ++i)
vec4_sub(M[i], a[i], b[i]);
}
-static inline void mat4x4_scale(mat4x4 M, mat4x4 a, float k)
+static inline void mat4x4_scale_isotropic(mat4x4 M, mat4x4 a, float k)
{
int i;
for(i=0; i<4; ++i)
vec4_scale(M[i], a[i], k);
}
+static inline void mat4x4_scale(mat4x4 R, mat4x4 M, float sx, float sy, float sz)
+{
+ vec4_scale(R[0], M[0], sx);
+ vec4_scale(R[1], M[1], sy);
+ vec4_scale(R[2], M[2], sz);
+}
static inline void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b)
{
int k, r, c;
@@ -183,14 +189,14 @@ static inline void mat4x4_rotate(mat4x4 Q, mat4x4 M, float x, float y, float z,
{ u[1], -u[0], 0, 0},
{ 0, 0, 0, 1}
};
- mat4x4_scale(S, S, s);
+ mat4x4_scale_isotropic(S, S, s);
mat4x4 R;
mat4x4_from_vec3_mul_outer(R, u, u);
mat4x4_identity(T);
mat4x4_sub(T, T, Q);
T[3][3] = 0.;
- mat4x4_scale(T, T, c);
+ mat4x4_scale_isotropic(T, T, c);
mat4x4_add(R, R, T);
mat4x4_add(Q, R, S);
@@ -413,7 +419,7 @@ static inline void mat4x4_mul_quat(mat4x4 R, mat4x4 M, quat q)
}
static inline void quat_from_mat4x4(quat q, mat4x4 M)
{
- float r=0., r2;
+ float r=0.;
int i;
int perm[] = { 0, 1, 2, 0, 1 };