Implemented Matrix3x3::ForwardDir, BackwardDir, LeftDir, RightDir, UpDir, DownDir return normalized relative direction vectors.

This commit is contained in:
2025-02-02 22:08:48 -05:00
parent 250c745969
commit 437113437f
2 changed files with 20 additions and 0 deletions

View File

@@ -161,6 +161,14 @@ namespace J3ML::LinearAlgebra {
/// Sets this matrix to perform the rotation expressed by the given quaternion.
void SetRotatePart(const Quaternion& quat);
Vector3 ForwardDir() const;
Vector3 BackwardDir() const;
Vector3 LeftDir() const;
Vector3 RightDir() const;
Vector3 UpDir() const;
Vector3 DownDir() const;
/// Returns the given row.
/** @param row The zero-based index [0, 2] of the row to get. */
Vector3 GetRow(int index) const;

View File

@@ -1087,6 +1087,18 @@ namespace J3ML::LinearAlgebra {
return m;
}
Vector3 Matrix3x3::ForwardDir() const { return Col(2).Normalized(); }
Vector3 Matrix3x3::BackwardDir() const { return -Col(2).Normalized(); }
Vector3 Matrix3x3::LeftDir() const { return -Col(0).Normalized(); }
Vector3 Matrix3x3::RightDir() const { return Col(0).Normalized(); }
Vector3 Matrix3x3::UpDir() const { return Col(1).Normalized(); }
Vector3 Matrix3x3::DownDir() const { return -Col(1).Normalized(); }
}