mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 20:14:37 +00:00
common: precision increase while matrix inversion
A numerically motivated limit on the matrix determinant set at 1e-6 was not sufficient. The limit has been increased by checkoing whether 1/det is still a number.
This commit is contained in:
parent
c1c51fbc10
commit
6db6672567
2 changed files with 3 additions and 4 deletions
|
@ -120,9 +120,8 @@ bool inverse(const Matrix* m, Matrix* out)
|
|||
m->e12 * (m->e21 * m->e33 - m->e23 * m->e31) +
|
||||
m->e13 * (m->e21 * m->e32 - m->e22 * m->e31);
|
||||
|
||||
if (tvg::zero(det)) return false;
|
||||
|
||||
auto invDet = 1 / det;
|
||||
auto invDet = 1.0f / det;
|
||||
if (!std::isfinite(invDet)) return false;
|
||||
|
||||
out->e11 = (m->e22 * m->e33 - m->e32 * m->e23) * invDet;
|
||||
out->e12 = (m->e13 * m->e32 - m->e12 * m->e33) * invDet;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#define _USE_MATH_DEFINES
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "tvgCommon.h"
|
||||
|
||||
namespace tvg
|
||||
|
|
Loading…
Add table
Reference in a new issue