mat3: nml::mat3& operator+=(const nml::mat3& other)
Add a mat3 to the current mat3.
The sum between two mat3 is calculated this way:
\(\begin{bmatrix} x.x & y.x & z.x \\ x.y & y.y & z.y \\ x.z & y.z & z.z \end{bmatrix} + \begin{bmatrix} other.x.x & other.y.x & other.z.x \\ other.x.y & other.y.y & other.z.y \\ other.x.z & other.y.z & other.z.z \end{bmatrix} =\)
\(\begin{bmatrix} x.x + other.x.x & y.x + other.y.x & z.x + other.z.x \\ x.y + other.x.y & y.y + other.y.y & z.y + other.z.y \\ x.z + other.x.z & y.z + other.y.z & z.z + other.z.z \end{bmatrix}\)
Example
#include "include/mat3.h"
#include <iostream>
int main() {
nml::mat3 a(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f);
nml::mat3 b(3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f);
a += b;
std::cout << nml::to_string(a) << std::endl;
return 0;
}
Result:
[[4.000000, 6.000000, 8.000000], [10.000000, 12.000000, 14.000000], [16.000000, 18.000000, 20.000000]]