Before it was one constructor using bool parameter, which is massive
antipattern:
Matrix4 m(false); // Huh? No Matrix4 then or what?
Iẗ́'s now separated into two distinct constructors, of them one can be
already declared as constexpr (hooray). The usage is as follows:
Matrix4 a; // Default (identity matrix)
Matrix4 b(Matrix4::Identity); // Explicitly identity matrix
Matrix4 c(Matrix4::Zero); // Zero-filled matrix
Also deleted constructor from one parameter, so following mistakes
now cannot compile:
Matrix4 d(true); // Both would set element at [0][0] to 1,
Matrix4 e(Matrix3::Zero); // and other to 0
Removed functions at(), set() and add(), everything (and more) can be
now done using operator[]. Accessing matrix elements is now done through
column vectors, e.g.:
Matrix4 a;
a.at(row, col); // before
a[col][row]; // now
Note that because operator[] on Matrix returns column vector (there is
nothing like row vector), the parameter "order" is now swapped.
Types saved inside Matrix and Vector will be at most time smaller than
or the same size as references to them, so no move semantic and
forwarding is necessary.
It should improve performance, because what can be computed at compile
time is now computed at compile time. In addition these things have been
changed or improved:
* Removed constructors from T*, as they cannot be AFAIK written using
constexpr functions only and they only do unnecessary data copying
most of the time. The functionality is now provided using static
functions Matrix*::from() and Vector*::from() which returns either
const or non-const reference to original data, so no copy is
performed. These functions also have explicit warning about unsafe
operations.
* Defaulted copy constructors and assignment operators, using
"default initialization" for arrays instead of memsetting it with
zeros. It should behave the same and this way we don't need any
memcpy(), memset() etc. from <cstring>, which is good.
Multiplication, division, addition and substraction is now done
primarily in assigning operators, as they do the computations in-place,
so they are more memory efficient than implementing them using e.g.
`*this = *this+other;`.
Updated unit test only for matrix multiplication, as vector unit tests
test arithmetic asssign operators too.
Mainly to be consistent with Matrix::transposed() function name,
furthermore calling
Matrix::inverse()
could look like the original matrix is being inversed, while calling
Matrix::inversed()
implies that the function doesn't change the original matrix, but
returns the result instead.