libvmath4

diff src/matrix.inl @ 0:4d6383605d64

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 05 Oct 2014 04:00:05 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/matrix.inl	Sun Oct 05 04:00:05 2014 +0300
     1.3 @@ -0,0 +1,45 @@
     1.4 +#include <string.h>
     1.5 +
     1.6 +Matrix3x3 Matrix3x3::id = Matrix3x3(1, 0, 0, 0, 1, 0, 0, 0, 1);
     1.7 +Matrix4x4 Matrix4x4::id = Matrix4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
     1.8 +
     1.9 +Matrix3x3::Matrix3x3()
    1.10 +{
    1.11 +	memcpy(m, Matrix3x3::id.m, sizeof m);
    1.12 +}
    1.13 +
    1.14 +Matrix3x3::Matrix3x3(const float *m)
    1.15 +{
    1.16 +	memcpy(this->m, m, sizeof this->m);
    1.17 +}
    1.18 +
    1.19 +Matrix3x3::Matrix3x3(float m00, float m01, float m02,
    1.20 +					float m10, float m11, float m12,
    1.21 +					float m20, float m21, float m22)
    1.22 +{
    1.23 +	m[0][0] = m00; m[0][1] = m01; m[0][2] = m02;
    1.24 +	m[1][0] = m10; m[1][1] = m11; m[1][2] = m12;
    1.25 +	m[2][0] = m20; m[2][1] = m21; m[2][2] = m22;
    1.26 +}
    1.27 +
    1.28 +
    1.29 +Matrix4x4::Matrix4x4()
    1.30 +{
    1.31 +	memcpy(m, Matrix4x4::id.m, sizeof m);
    1.32 +}
    1.33 +
    1.34 +Matrix4x4::Matrix4x4(const float *m)
    1.35 +{
    1.36 +	memcpy(this->m, m, sizeof this->m);
    1.37 +}
    1.38 +
    1.39 +Matrix4x4::Matrix4x4(float m00, float m01, float m02, float m03,
    1.40 +					float m10, float m11, float m12, float m13,
    1.41 +					float m20, float m21, float m22, float m23,
    1.42 +					float m30, float m31, float m32, float m33)
    1.43 +{
    1.44 +	m[0][0] = m00; m[0][1] = m01; m[0][2] = m02; m[0][3] = m03;
    1.45 +	m[1][0] = m10; m[1][1] = m11; m[1][2] = m12; m[1][3] = m13;
    1.46 +	m[2][0] = m20; m[2][1] = m21; m[2][2] = m22; m[2][3] = m23;
    1.47 +	m[3][0] = m20; m[3][1] = m21; m[3][2] = m22; m[3][3] = m23;
    1.48 +}