Implement M3x3::SetColumn

This commit is contained in:
2024-01-15 15:17:39 -05:00
parent 1eae732718
commit 03f0193df7
2 changed files with 19 additions and 18 deletions

View File

@@ -5,25 +5,19 @@
namespace LinearAlgebra {
/// A 4-by-4 matrix for affine transformations and perspective projections of 3D geometry.
/* This matrix can represent the most generic form of transformations for 3D objects,
* including perspective projections, which a 4-by-3 cannot store,
* and translations, which a 3-by-3 cannot represent.
* The elements of this matrix are
* m_00, m_01, m_02, m_03
* m_10, m_11, m_12, m_13
* m_20, m_21, m_22, xm_23,
* m_30, m_31, m_32, m_33
*
* The element m_yx is the value on the row y and column x.
* You can access m_yx using the double-bracket notation m[y][x]
*/
/* This matrix can represent the most generic form of transformations for 3D objects,
* including perspective projections, which a 4-by-3 cannot store,
* and translations, which a 3-by-3 cannot represent.
* The elements of this matrix are
* m_00, m_01, m_02, m_03
* m_10, m_11, m_12, m_13
* m_20, m_21, m_22, am_23,
* m_30, m_31, m_32, m_33
*
* The element m_yx is the value on the row y and column x.
* You can access m_yx using the double-bracket notation m[y][x]
*/
class Matrix4x4 {
public:
enum { Rows = 4 };

View File

@@ -228,6 +228,13 @@ namespace LinearAlgebra {
elems[i][2] = vec.z;
}
void Matrix3x3::SetColumn(int i, const Vector3& vec)
{
elems[0][i] = vec.x;
elems[1][i] = vec.y;
elems[2][i] = vec.z;
}
Matrix3x3
Matrix3x3::LookAt(const Vector3 &forward, const Vector3 &target, const Vector3 &localUp, const Vector3 &worldUp) {
// User must input proper normalized input direction vectors