diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2022-01-12 00:54:14 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-12 01:08:38 +0100 |
commit | a41d5ffa1e8bdb8c774df2418fae10740fec75dc (patch) | |
tree | 700ce9df7f2892b673bce48d15d657b896e87dbe /Userland/Libraries/LibGfx | |
parent | b2e0bf24efd1e9f0f2ac507561437d28bd8d535d (diff) | |
download | serenity-a41d5ffa1e8bdb8c774df2418fae10740fec75dc.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r-- | Userland/Libraries/LibGfx/Matrix.h | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Userland/Libraries/LibGfx/Matrix.h b/Userland/Libraries/LibGfx/Matrix.h index 33f9536ce2..2e251de293 100644 --- a/Userland/Libraries/LibGfx/Matrix.h +++ b/Userland/Libraries/LibGfx/Matrix.h @@ -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 |