From: havoc Date: Wed, 20 Nov 2002 11:18:50 +0000 (+0000) Subject: removed all 3x4 matrix support (wasn't used, and isn't likely to ever be used) X-Git-Tag: RELEASE_0_2_0_RC1~63 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7ee749965766a657fa909ea42a783177929519f1;p=xonotic%2Fdarkplaces.git removed all 3x4 matrix support (wasn't used, and isn't likely to ever be used) moved Matrix4x4_Print to mathlib.[ch] because it really doesn't belong in the entirely quake-independent matrixlib.[ch] git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2639 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/mathlib.c b/mathlib.c index 96090b50..a0e328d0 100644 --- a/mathlib.c +++ b/mathlib.c @@ -31,7 +31,7 @@ float m_bytenormals[NUMVERTEXNORMALS][3] = { {-0.525731, 0.000000, 0.850651}, {-0.442863, 0.238856, 0.864188}, {-0.295242, 0.000000, 0.955423}, {-0.309017, 0.500000, 0.809017}, -{-0.162460, 0.262866, 0.951056}, {0.000000, 0.000000, 1.000000}, +{-0.162460, 0.262866, 0.951056}, {0.000000, 0.000000, 1.000000}, {0.000000, 0.850651, 0.525731}, {-0.147621, 0.716567, 0.681718}, {0.147621, 0.716567, 0.681718}, {0.000000, 0.525731, 0.850651}, {0.309017, 0.500000, 0.809017}, {0.525731, 0.000000, 0.850651}, @@ -64,7 +64,7 @@ float m_bytenormals[NUMVERTEXNORMALS][3] = {0.525731, 0.000000, -0.850651}, {0.681718, 0.147621, -0.716567}, {0.681718, -0.147621, -0.716567}, {0.850651, 0.000000, -0.525731}, {0.809017, -0.309017, -0.500000}, {0.864188, -0.442863, -0.238856}, -{0.951056, -0.162460, -0.262866}, {0.147621, 0.716567, -0.681718}, +{0.951056, -0.162460, -0.262866}, {0.147621, 0.716567, -0.681718}, {0.309017, 0.500000, -0.809017}, {0.425325, 0.688191, -0.587785}, {0.442863, 0.238856, -0.864188}, {0.587785, 0.425325, -0.688191}, {0.688191, 0.587785, -0.425325}, {-0.147621, 0.716567, -0.681718}, @@ -498,3 +498,13 @@ void Mathlib_Init(void) ixtable[a] = 1.0f / a; } +#include "matrixlib.h" + +void Matrix4x4_Print (const matrix4x4_t *in) +{ + Con_Printf("%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n" + , in->m[0][0], in->m[0][1], in->m[0][2], in->m[0][3] + , in->m[1][0], in->m[1][1], in->m[1][2], in->m[1][3] + , in->m[2][0], in->m[2][1], in->m[2][2], in->m[2][3] + , in->m[3][0], in->m[3][1], in->m[3][2], in->m[3][3]); +} diff --git a/mathlib.h b/mathlib.h index 8cb2e75b..fc5d6cd0 100644 --- a/mathlib.h +++ b/mathlib.h @@ -176,5 +176,9 @@ tinydoubleplane_t; void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, float degrees); +// print a matrix to the console +struct matrix4x4_s; +void Matrix4x4_Print(const struct matrix4x4_s *in); + #endif diff --git a/matrixlib.c b/matrixlib.c index 7d6db2ec..6edcf8a4 100644 --- a/matrixlib.c +++ b/matrixlib.c @@ -1,5 +1,4 @@ -#include "quakedef.h" #include "matrixlib.h" #include @@ -48,26 +47,6 @@ void Matrix4x4_CopyTranslateOnly (matrix4x4_t *out, const matrix4x4_t *in) out->m[3][3] = 1.0f; } -void Matrix4x4_FromMatrix3x4 (matrix4x4_t *out, const matrix3x4_t *in) -{ - out->m[0][0] = in->m[0][0]; - out->m[0][1] = in->m[0][1]; - out->m[0][2] = in->m[0][2]; - out->m[0][3] = in->m[0][3]; - out->m[1][0] = in->m[1][0]; - out->m[1][1] = in->m[1][1]; - out->m[1][2] = in->m[1][2]; - out->m[1][3] = in->m[1][3]; - out->m[2][0] = in->m[2][0]; - out->m[2][1] = in->m[2][1]; - out->m[2][2] = in->m[2][2]; - out->m[2][3] = in->m[2][3]; - out->m[3][0] = 0.0f; - out->m[3][1] = 0.0f; - out->m[3][2] = 0.0f; - out->m[3][3] = 1.0f; -} - void Matrix4x4_Concat (matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2) { out->m[0][0] = in1->m[0][0] * in2->m[0][0] + in1->m[0][1] * in2->m[1][0] + in1->m[0][2] * in2->m[2][0] + in1->m[0][3] * in2->m[3][0]; @@ -420,362 +399,3 @@ void Matrix4x4_ConcatScale3 (matrix4x4_t *out, float x, float y, float z) Matrix4x4_Concat(out, &base, &temp); } -void Matrix4x4_Print (const matrix4x4_t *in) -{ - Con_Printf("%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n" - , in->m[0][0], in->m[0][1], in->m[0][2], in->m[0][3] - , in->m[1][0], in->m[1][1], in->m[1][2], in->m[1][3] - , in->m[2][0], in->m[2][1], in->m[2][2], in->m[2][3] - , in->m[3][0], in->m[3][1], in->m[3][2], in->m[3][3]); -} - - - - - - - -void Matrix3x4_Copy (matrix3x4_t *out, const matrix3x4_t *in) -{ - *out = *in; -} - -void Matrix3x4_CopyRotateOnly (matrix3x4_t *out, const matrix3x4_t *in) -{ - out->m[0][0] = in->m[0][0]; - out->m[0][1] = in->m[0][1]; - out->m[0][2] = in->m[0][2]; - out->m[0][3] = 0.0f; - out->m[1][0] = in->m[1][0]; - out->m[1][1] = in->m[1][1]; - out->m[1][2] = in->m[1][2]; - out->m[1][3] = 0.0f; - out->m[2][0] = in->m[2][0]; - out->m[2][1] = in->m[2][1]; - out->m[2][2] = in->m[2][2]; - out->m[2][3] = 0.0f; -} - -void Matrix3x4_CopyTranslateOnly (matrix3x4_t *out, const matrix3x4_t *in) -{ - out->m[0][0] = 0.0f; - out->m[0][1] = 0.0f; - out->m[0][2] = 0.0f; - out->m[0][3] = in->m[0][3]; - out->m[1][0] = 0.0f; - out->m[1][1] = 0.0f; - out->m[1][2] = 0.0f; - out->m[1][3] = in->m[1][3]; - out->m[2][0] = 0.0f; - out->m[2][1] = 0.0f; - out->m[2][2] = 0.0f; - out->m[2][3] = in->m[2][3]; -} - -void Matrix3x4_FromMatrix4x4 (matrix3x4_t *out, const matrix4x4_t *in) -{ - out->m[0][0] = in->m[0][0]; - out->m[0][1] = in->m[0][1]; - out->m[0][2] = in->m[0][2]; - out->m[0][3] = in->m[0][3]; - out->m[1][0] = in->m[1][0]; - out->m[1][1] = in->m[1][1]; - out->m[1][2] = in->m[1][2]; - out->m[1][3] = in->m[1][3]; - out->m[2][0] = in->m[2][0]; - out->m[2][1] = in->m[2][1]; - out->m[2][2] = in->m[2][2]; - out->m[2][3] = in->m[2][3]; -} - -void Matrix3x4_Concat (matrix3x4_t *out, const matrix3x4_t *in1, const matrix3x4_t *in2) -{ - out->m[0][0] = in1->m[0][0] * in2->m[0][0] + in1->m[0][1] * in2->m[1][0] + in1->m[0][2] * in2->m[2][0]; - out->m[0][1] = in1->m[0][0] * in2->m[0][1] + in1->m[0][1] * in2->m[1][1] + in1->m[0][2] * in2->m[2][1]; - out->m[0][2] = in1->m[0][0] * in2->m[0][2] + in1->m[0][1] * in2->m[1][2] + in1->m[0][2] * in2->m[2][2]; - out->m[0][3] = in1->m[0][0] * in2->m[0][3] + in1->m[0][1] * in2->m[1][3] + in1->m[0][2] * in2->m[2][3] + in1->m[0][3]; - out->m[1][0] = in1->m[1][0] * in2->m[0][0] + in1->m[1][1] * in2->m[1][0] + in1->m[1][2] * in2->m[2][0]; - out->m[1][1] = in1->m[1][0] * in2->m[0][1] + in1->m[1][1] * in2->m[1][1] + in1->m[1][2] * in2->m[2][1]; - out->m[1][2] = in1->m[1][0] * in2->m[0][2] + in1->m[1][1] * in2->m[1][2] + in1->m[1][2] * in2->m[2][2]; - out->m[1][3] = in1->m[1][0] * in2->m[0][3] + in1->m[1][1] * in2->m[1][3] + in1->m[1][2] * in2->m[2][3] + in1->m[1][3]; - out->m[2][0] = in1->m[2][0] * in2->m[0][0] + in1->m[2][1] * in2->m[1][0] + in1->m[2][2] * in2->m[2][0]; - out->m[2][1] = in1->m[2][0] * in2->m[0][1] + in1->m[2][1] * in2->m[1][1] + in1->m[2][2] * in2->m[2][1]; - out->m[2][2] = in1->m[2][0] * in2->m[0][2] + in1->m[2][1] * in2->m[1][2] + in1->m[2][2] * in2->m[2][2]; - out->m[2][3] = in1->m[2][0] * in2->m[0][3] + in1->m[2][1] * in2->m[1][3] + in1->m[2][2] * in2->m[2][3] + in1->m[2][3]; -} - -void Matrix3x4_Transpose3x3 (matrix3x4_t *out, const matrix3x4_t *in1) -{ - out->m[0][0] = in1->m[0][0]; - out->m[0][1] = in1->m[1][0]; - out->m[0][2] = in1->m[2][0]; - out->m[0][3] = 0.0f; - out->m[1][0] = in1->m[0][1]; - out->m[1][1] = in1->m[1][1]; - out->m[1][2] = in1->m[2][1]; - out->m[1][3] = 0.0f; - out->m[2][0] = in1->m[0][2]; - out->m[2][1] = in1->m[1][2]; - out->m[2][2] = in1->m[2][2]; - out->m[2][3] = 0.0f; -} - -void Matrix3x4_Invert_Simple (matrix3x4_t *out, const matrix3x4_t *in1) -{ - // we only support uniform scaling, so assume the first row is enough - // (note the lack of sqrt here, because we're trying to undo the scaling, - // this means multiplying by the inverse scale twice - squaring it, which - // makes the sqrt a waste of time) -#if 1 - double scale = 1.0 / (in1->m[0][0] * in1->m[0][0] + in1->m[0][1] * in1->m[0][1] + in1->m[0][2] * in1->m[0][2]); -#else - double scale = 3.0 / sqrt - (in1->m[0][0] * in1->m[0][0] + in1->m[0][1] * in1->m[0][1] + in1->m[0][2] * in1->m[0][2] - + in1->m[1][0] * in1->m[1][0] + in1->m[1][1] * in1->m[1][1] + in1->m[1][2] * in1->m[1][2] - + in1->m[2][0] * in1->m[2][0] + in1->m[2][1] * in1->m[2][1] + in1->m[2][2] * in1->m[2][2]); - scale *= scale; -#endif - - // invert the rotation by transposing and multiplying by the squared - // recipricol of the input matrix scale as described above - out->m[0][0] = in1->m[0][0] * scale; - out->m[0][1] = in1->m[1][0] * scale; - out->m[0][2] = in1->m[2][0] * scale; - out->m[1][0] = in1->m[0][1] * scale; - out->m[1][1] = in1->m[1][1] * scale; - out->m[1][2] = in1->m[2][1] * scale; - out->m[2][0] = in1->m[0][2] * scale; - out->m[2][1] = in1->m[1][2] * scale; - out->m[2][2] = in1->m[2][2] * scale; - - // invert the translate - out->m[0][3] = -(in1->m[0][3] * out->m[0][0] + in1->m[1][3] * out->m[0][1] + in1->m[2][3] * out->m[0][2]); - out->m[1][3] = -(in1->m[0][3] * out->m[1][0] + in1->m[1][3] * out->m[1][1] + in1->m[2][3] * out->m[1][2]); - out->m[2][3] = -(in1->m[0][3] * out->m[2][0] + in1->m[1][3] * out->m[2][1] + in1->m[2][3] * out->m[2][2]); -} - - -void Matrix3x4_CreateIdentity (matrix3x4_t *out) -{ - out->m[0][0]=1.0f; - out->m[0][1]=0.0f; - out->m[0][2]=0.0f; - out->m[0][3]=0.0f; - out->m[1][0]=0.0f; - out->m[1][1]=1.0f; - out->m[1][2]=0.0f; - out->m[1][3]=0.0f; - out->m[2][0]=0.0f; - out->m[2][1]=0.0f; - out->m[2][2]=1.0f; - out->m[2][3]=0.0f; -} - -void Matrix3x4_CreateTranslate (matrix3x4_t *out, float x, float y, float z) -{ - out->m[0][0]=1.0f; - out->m[0][1]=0.0f; - out->m[0][2]=0.0f; - out->m[0][3]=x; - out->m[1][0]=0.0f; - out->m[1][1]=1.0f; - out->m[1][2]=0.0f; - out->m[1][3]=y; - out->m[2][0]=0.0f; - out->m[2][1]=0.0f; - out->m[2][2]=1.0f; - out->m[2][3]=z; -} - -void Matrix3x4_CreateRotate (matrix3x4_t *out, float angle, float x, float y, float z) -{ - float len, c, s; - - len = x*x+y*y+z*z; - if (len != 0.0f) - len = 1.0f / sqrt(len); - x *= len; - y *= len; - z *= len; - - angle *= M_PI / 180.0; - c = cos(angle); - s = sin(angle); - - out->m[0][0]=x * x + c * (1 - x * x); - out->m[0][1]=x * y * (1 - c) + z * s; - out->m[0][2]=z * x * (1 - c) - y * s; - out->m[0][3]=0.0f; - out->m[1][0]=x * y * (1 - c) - z * s; - out->m[1][1]=y * y + c * (1 - y * y); - out->m[1][2]=y * z * (1 - c) + x * s; - out->m[1][3]=0.0f; - out->m[2][0]=z * x * (1 - c) + y * s; - out->m[2][1]=y * z * (1 - c) - x * s; - out->m[2][2]=z * z + c * (1 - z * z); - out->m[2][3]=0.0f; -} - -void Matrix3x4_CreateScale (matrix3x4_t *out, float x) -{ - out->m[0][0]=x; - out->m[0][1]=0.0f; - out->m[0][2]=0.0f; - out->m[0][3]=0.0f; - out->m[1][0]=0.0f; - out->m[1][1]=x; - out->m[1][2]=0.0f; - out->m[1][3]=0.0f; - out->m[2][0]=0.0f; - out->m[2][1]=0.0f; - out->m[2][2]=x; - out->m[2][3]=0.0f; -} - -void Matrix3x4_CreateScale3 (matrix3x4_t *out, float x, float y, float z) -{ - out->m[0][0]=x; - out->m[0][1]=0.0f; - out->m[0][2]=0.0f; - out->m[0][3]=0.0f; - out->m[1][0]=0.0f; - out->m[1][1]=y; - out->m[1][2]=0.0f; - out->m[1][3]=0.0f; - out->m[2][0]=0.0f; - out->m[2][1]=0.0f; - out->m[2][2]=z; - out->m[2][3]=0.0f; -} - -void Matrix3x4_CreateFromQuakeEntity(matrix3x4_t *out, float x, float y, float z, float pitch, float yaw, float roll, float scale) -{ - double angle, sr, sp, sy, cr, cp, cy; - - angle = yaw * (M_PI*2 / 360); - sy = sin(angle); - cy = cos(angle); - angle = pitch * (M_PI*2 / 360); - sp = sin(angle); - cp = cos(angle); - angle = roll * (M_PI*2 / 360); - sr = sin(angle); - cr = cos(angle); - out->m[0][0] = (cp*cy) * scale; - out->m[0][1] = (sr*sp*cy+cr*-sy) * scale; - out->m[0][2] = (cr*sp*cy+-sr*-sy) * scale; - out->m[0][3] = x; - out->m[1][0] = (cp*sy) * scale; - out->m[1][1] = (sr*sp*sy+cr*cy) * scale; - out->m[1][2] = (cr*sp*sy+-sr*cy) * scale; - out->m[1][3] = y; - out->m[2][0] = (-sp) * scale; - out->m[2][1] = (sr*cp) * scale; - out->m[2][2] = (cr*cp) * scale; - out->m[2][3] = z; -} - -void Matrix3x4_ToVectors(const matrix3x4_t *in, float vx[3], float vy[3], float vz[3], float t[3]) -{ - vx[0] = in->m[0][0]; - vx[1] = in->m[1][0]; - vx[2] = in->m[2][0]; - vy[0] = in->m[0][1]; - vy[1] = in->m[1][1]; - vy[2] = in->m[2][1]; - vz[0] = in->m[0][2]; - vz[1] = in->m[1][2]; - vz[2] = in->m[2][2]; - t[0] = in->m[0][3]; - t[1] = in->m[1][3]; - t[2] = in->m[2][3]; -} - -void Matrix3x4_FromVectors(matrix3x4_t *out, const float vx[3], const float vy[3], const float vz[3], const float t[3]) -{ - out->m[0][0] = vx[0]; - out->m[0][1] = vy[0]; - out->m[0][2] = vz[0]; - out->m[0][3] = t[0]; - out->m[1][0] = vx[1]; - out->m[1][1] = vy[1]; - out->m[1][2] = vz[1]; - out->m[1][3] = t[1]; - out->m[2][0] = vx[2]; - out->m[2][1] = vy[2]; - out->m[2][2] = vz[2]; - out->m[2][3] = t[2]; -} - -void Matrix3x4_Transform (const matrix3x4_t *in, const float v[3], float out[3]) -{ - out[0] = v[0] * in->m[0][0] + v[1] * in->m[0][1] + v[2] * in->m[0][2] + in->m[0][3]; - out[1] = v[0] * in->m[1][0] + v[1] * in->m[1][1] + v[2] * in->m[1][2] + in->m[1][3]; - out[2] = v[0] * in->m[2][0] + v[1] * in->m[2][1] + v[2] * in->m[2][2] + in->m[2][3]; -} - -/* -void Matrix3x4_SimpleUntransform (const matrix3x4_t *in, const float v[3], float out[3]) -{ - float t[3]; - t[0] = v[0] - in->m[0][3]; - t[1] = v[1] - in->m[1][3]; - t[2] = v[2] - in->m[2][3]; - out[0] = t[0] * in->m[0][0] + t[1] * in->m[1][0] + t[2] * in->m[2][0]; - out[1] = t[0] * in->m[0][1] + t[1] * in->m[1][1] + t[2] * in->m[2][1]; - out[2] = t[0] * in->m[0][2] + t[1] * in->m[1][2] + t[2] * in->m[2][2]; -} -*/ - -void Matrix3x4_Transform3x3 (const matrix3x4_t *in, const float v[3], float out[3]) -{ - out[0] = v[0] * in->m[0][0] + v[1] * in->m[0][1] + v[2] * in->m[0][2] + in->m[0][3]; - out[1] = v[0] * in->m[1][0] + v[1] * in->m[1][1] + v[2] * in->m[1][2] + in->m[1][3]; - out[2] = v[0] * in->m[2][0] + v[1] * in->m[2][1] + v[2] * in->m[2][2] + in->m[2][3]; -} - - -// FIXME: optimize -void Matrix3x4_ConcatTranslate (matrix3x4_t *out, float x, float y, float z) -{ - matrix3x4_t base, temp; - base = *out; - Matrix3x4_CreateTranslate(&temp, x, y, z); - Matrix3x4_Concat(out, &base, &temp); -} - -// FIXME: optimize -void Matrix3x4_ConcatRotate (matrix3x4_t *out, float angle, float x, float y, float z) -{ - matrix3x4_t base, temp; - base = *out; - Matrix3x4_CreateRotate(&temp, angle, x, y, z); - Matrix3x4_Concat(out, &base, &temp); -} - -// FIXME: optimize -void Matrix3x4_ConcatScale (matrix3x4_t *out, float x) -{ - matrix3x4_t base, temp; - base = *out; - Matrix3x4_CreateScale(&temp, x); - Matrix3x4_Concat(out, &base, &temp); -} - -// FIXME: optimize -void Matrix3x4_ConcatScale3 (matrix3x4_t *out, float x, float y, float z) -{ - matrix3x4_t base, temp; - base = *out; - Matrix3x4_CreateScale3(&temp, x, y, z); - Matrix3x4_Concat(out, &base, &temp); -} - -void Matrix3x4_Print (const matrix3x4_t *in) -{ - Con_Printf("%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n" - , in->m[0][0], in->m[0][1], in->m[0][2], in->m[0][3] - , in->m[1][0], in->m[1][1], in->m[1][2], in->m[1][3] - , in->m[2][0], in->m[2][1], in->m[2][2], in->m[2][3]); -} - diff --git a/matrixlib.h b/matrixlib.h index d8d14752..23150179 100644 --- a/matrixlib.h +++ b/matrixlib.h @@ -8,12 +8,6 @@ typedef struct matrix4x4_s } matrix4x4_t; -typedef struct matrix3x4_s -{ - float m[3][4]; -} -matrix3x4_t; - // functions for manipulating 4x4 matrices // copy a matrix4x4 @@ -22,8 +16,6 @@ void Matrix4x4_Copy (matrix4x4_t *out, const matrix4x4_t *in); void Matrix4x4_CopyRotateOnly (matrix4x4_t *out, const matrix4x4_t *in); // copy only the translate portion of a matrix4x4 void Matrix4x4_CopyTranslateOnly (matrix4x4_t *out, const matrix4x4_t *in); -// make a matrix4x4 from a matrix3x4 -void Matrix4x4_FromMatrix3x4 (matrix4x4_t *out, const matrix3x4_t *in); // multiply two matrix4x4 together, combining their transformations // (warning: order matters - Concat(a, b, c) != Concat(a, c, b)) void Matrix4x4_Concat (matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2); @@ -86,76 +78,4 @@ void Matrix4x4_ConcatScale (matrix4x4_t *out, float x); // immediately applies a Scale3 to the matrix void Matrix4x4_ConcatScale3 (matrix4x4_t *out, float x, float y, float z); -// print a matrix to the console -void Matrix4x4_Print(const matrix4x4_t *in); - - -// functions for manipulating 3x4 matrices - -// copy a matrix3x4 -void Matrix3x4_Copy (matrix3x4_t *out, const matrix3x4_t *in); -// copy only the rotation portion of a matrix3x4 -void Matrix3x4_CopyRotateOnly (matrix3x4_t *out, const matrix3x4_t *in); -// copy only the translate portion of a matrix3x4 -void Matrix3x4_CopyTranslateOnly (matrix3x4_t *out, const matrix3x4_t *in); -// make a matrix3x4 from a matrix4x4 -void Matrix3x4_FromMatrix4x4 (matrix3x4_t *out, const matrix4x4_t *in); -// multiply two matrix3x4 together, combining their transformations -// (warning: order matters - Concat(a, b, c) != Concat(a, c, b)) -void Matrix3x4_Concat (matrix3x4_t *out, const matrix3x4_t *in1, const matrix3x4_t *in2); -// swaps the rows and columns of the rotation matrix -// (inverting the rotation, but leaving everything else the same) -void Matrix3x4_Transpose3x3 (matrix3x4_t *out, const matrix3x4_t *in1); -// creates a matrix that does the opposite of the matrix provided -// only supports translate, rotate, scale (not scale3) matrices -void Matrix3x4_Invert_Simple (matrix3x4_t *out, const matrix3x4_t *in1); - -// creates an identity matrix -// (a matrix which does nothing) -void Matrix3x4_CreateIdentity (matrix3x4_t *out); -// creates a translate matrix -// (moves vectors) -void Matrix3x4_CreateTranslate (matrix3x4_t *out, float x, float y, float z); -// creates a rotate matrix -// (rotates vectors) -void Matrix3x4_CreateRotate (matrix3x4_t *out, float angle, float x, float y, float z); -// creates a scaling matrix -// (expands or contracts vectors) -// (warning: do not apply this kind of matrix to direction vectors) -void Matrix3x4_CreateScale (matrix3x4_t *out, float x); -// creates a squishing matrix -// (expands or contracts vectors differently in different axis) -// (warning: this is not reversed by Invert_Simple) -// (warning: do not apply this kind of matrix to direction vectors) -void Matrix3x4_CreateScale3 (matrix3x4_t *out, float x, float y, float z); -// creates a matrix for a quake entity -void Matrix3x4_CreateFromQuakeEntity(matrix3x4_t *out, float x, float y, float z, float pitch, float yaw, float roll, float scale); - -// converts a matrix3x4 to a set of 3D vectors for the 3 axial directions, and the translate -void Matrix3x4_ToVectors(const matrix3x4_t *in, float vx[3], float vy[3], float vz[3], float t[3]); -// creates a matrix3x4 from a set of 3D vectors for axial directions, and translate -void Matrix3x4_FromVectors(matrix3x4_t *out, const float vx[3], const float vy[3], const float vz[3], const float t[3]); - -// transforms a 3D vector through a matrix3x4 -void Matrix3x4_Transform (const matrix3x4_t *in, const float v[3], float out[3]); -// reverse transforms a 3D vector through a matrix3x4, at least for *simple* -// cases (rotation and translation *ONLY*), this attempts to undo the results -// of Transform -//void Matrix3x4_SimpleUntransform (const matrix3x4_t *in, const float v[3], float out[3]); -// transforms a direction vector through the rotation part of a matrix -void Matrix3x4_Transform3x3 (const matrix3x4_t *in, const float v[3], float out[3]); - -// ease of use functions -// immediately applies a Translate to the matrix -void Matrix3x4_ConcatTranslate (matrix3x4_t *out, float x, float y, float z); -// immediately applies a Rotate to the matrix -void Matrix3x4_ConcatRotate (matrix3x4_t *out, float angle, float x, float y, float z); -// immediately applies a Scale to the matrix -void Matrix3x4_ConcatScale (matrix3x4_t *out, float x); -// immediately applies a Scale3 to the matrix -void Matrix3x4_ConcatScale3 (matrix3x4_t *out, float x, float y, float z); - -// print a matrix to the console -void Matrix3x4_Print(const matrix3x4_t *in); - #endif