mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:07:45 +00:00
LibGfx+LibGL: Allow singular matrices to be inverted
This is basically the old behavior before the GLtron port was introduced, but `.inverse()` no longer crashes if the matrix is singular.
This commit is contained in:
parent
b2e0bf24ef
commit
a41d5ffa1e
2 changed files with 5 additions and 12 deletions
|
@ -6,7 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Types.h>
|
||||
#include <initializer_list>
|
||||
|
||||
|
@ -159,12 +158,9 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr ErrorOr<Matrix> inverse() const
|
||||
[[nodiscard]] constexpr Matrix inverse() const
|
||||
{
|
||||
auto det = determinant();
|
||||
if (det == 0)
|
||||
return Error::from_string_literal("inverse of matrix does not exist"sv);
|
||||
return adjugate() / det;
|
||||
return adjugate() / determinant();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr Matrix transpose() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue