// Produces an zero filles matrix3 tmath::matrix<type,row, column> m1; // Initiates the vectorn<T,3> with values tmath::matrix<float,3,3> m2(0.0f, 1.0f, 25.65f, 0.0f, 1.0f, 0.0f, 1.0f, 2.0f, 3.0f); // Initiates the matrix3 by another matrix3 tmath::matrix<float,3,3> m3(v2); // Initiates the matrix3 by an array of values float values[9] = {0.0f, 1.0f, 25.65f, 0.0f, 1.0f, 0.0f, 1.0f, 2.0f, 3.0f}; tmath::matrix<float,3,3> m3(values);
tmath::matrix<float,3,3> m1; tmath::matrix<float,3,3> m2; tmath::matrix<float,3,3> m3; // Addition m3 = m1 + m2; m3 += m1; // Subtraction m3 = m1 - m2; m3 -= m1;
tmath::matrix<float,3,3> m1; tmath::matrix<float,3,3> m2; tmath::matrix<float,3,3> m3; // Multiplication with a matrix m3 = m1 * m2; // Multiplication with a scalar m2 = m1 * 1.0f; // Dito m3 = 1.0f * m1;
A matrix can be multiplicated with a vector, too. The resut is a vectorn<T,3>
tmath::matrix<float,3,3>> m1; tmath::vectorn<float,3> v1, res; res = m1 * v1;
tmath::matrix<float,3,3> m1,m2; tmath::null(m1); tmath::identity(m2);
To transpose a matrix use the transp() function
tmath::matrix<float,3,3> m(0.0f, 1.0f, 25.65f, 0.0f, 1.0f, 0.0f, 1.0f, 2.0f, 3.0f), mres; mres = tmath::transp(m);
If you need the inverse of the matrix use the inv() function:
tmath::matrix<float,3,3> m(0.0f, 1.0f, 25.65f, 0.0f, 1.0f, 0.0f, 1.0f, 2.0f, 3.0f), mres; mres = tmath::inv(m);
To calculate the determinant of the matrix use the det() function:
tmath::matrix<float,3,3> m(0.0f, 1.0f, 25.65f, 0.0f, 1.0f, 0.0f, 1.0f, 2.0f, 3.0f), mres; mres = tmath::det(m);
tmath::matrix<float,3,3 m1; float xx = m1.xx; float xy = m1.xy; float xz = m1.xz; float yx = m1.yx; float yy = m1.yy; float yz = m1.yz; ...
Second, you can use the matrix itself as a pointer of an array. You can access the components with the [] operator.
tmath::matrix<float,3,3> m1; float* v = m1; float xcomp = v[0]; // xx float ycomp = v[1]; // xy float zcomp = v[2]; // xz ...
Please keep in mind that the element access via the [] operator are not designed for security checking. This means no border checks are done.
tmath::matrix<float,3,3> m1; std::cout << m1 << std::endl;
tmath::matrix3 m1(....); tmath::matrix4 m2; tmath::conv(m1,m2);