Matrix4 m; m.set(0, 0, 1.0); m.set(1, 1, 2.0); m.set(2, 2, 3.0); m.set(3, 3, 1.0);
Matrix4 A, B, C; // ... initialize A and B ... C = A * B;
Matrix4 m; Vector3 v(1.0, 2.0, 3.0); v = m.transform(v);This code applies a translation transformation to a 3D vector v using a matrix m. The package/library which contains Matrix4 class may vary depending on the application or framework being used. However, Matrix4 class can be found in many popular graphics and game engines like OpenGL, Unity3D and Unreal Engine. Some third-party libraries like Eigen and GLM also provide Matrix4 class in C++.