LibGfx: Add Matrix::operator*(T scalar)

This commit is contained in:
MacDue 2022-10-01 22:38:06 +01:00 committed by Andreas Kling
parent 95878688a7
commit 3d532571bb
Notes: sideshowbarker 2024-07-17 06:26:23 +09:00

View file

@ -104,6 +104,21 @@ public:
return division;
}
friend constexpr Matrix operator*(Matrix const& matrix, T scalar)
{
Matrix scaled;
for (size_t i = 0; i < N; ++i) {
for (size_t j = 0; j < N; ++j)
scaled.m_elements[i][j] = matrix.m_elements[i][j] * scalar;
}
return scaled;
}
friend constexpr Matrix operator*(T scalar, Matrix const& matrix)
{
return matrix * scalar;
}
[[nodiscard]] constexpr Matrix adjugate() const
{
if constexpr (N == 1)