mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-23 22:58:44 +00:00
common math: promote matrix functions.
comparing matrices is a common mathmatical operation.
This commit is contained in:
parent
a74062d5f1
commit
3e8225a5ba
2 changed files with 10 additions and 5 deletions
|
@ -45,6 +45,15 @@ static inline bool mathEqual(float a, float b)
|
|||
return (fabsf(a - b) < FLT_EPSILON);
|
||||
}
|
||||
|
||||
static inline bool mathEqual(const Matrix& a, const Matrix& b)
|
||||
{
|
||||
if (!mathEqual(a.e11, b.e11) || !mathEqual(a.e12, b.e12) || !mathEqual(a.e13, b.e13) ||
|
||||
!mathEqual(a.e21, b.e21) || !mathEqual(a.e22, b.e22) || !mathEqual(a.e23, b.e23) ||
|
||||
!mathEqual(a.e31, b.e31) || !mathEqual(a.e32, b.e32) || !mathEqual(a.e33, b.e33)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool mathRightAngle(const Matrix* m)
|
||||
{
|
||||
|
|
|
@ -93,11 +93,7 @@ static bool _merge(Shape* from, Shape* to)
|
|||
auto t1 = from->transform();
|
||||
auto t2 = to->transform();
|
||||
|
||||
if (!mathEqual(t1.e11, t2.e11) || !mathEqual(t1.e12, t2.e12) || !mathEqual(t1.e13, t2.e13) ||
|
||||
!mathEqual(t1.e21, t2.e21) || !mathEqual(t1.e22, t2.e22) || !mathEqual(t1.e23, t2.e23) ||
|
||||
!mathEqual(t1.e31, t2.e31) || !mathEqual(t1.e32, t2.e32) || !mathEqual(t1.e33, t2.e33)) {
|
||||
return false;
|
||||
}
|
||||
if (!mathEqual(t1, t2)) return false;
|
||||
|
||||
//stroke
|
||||
if (P(from)->strokeFirst() != P(to)->strokeFirst()) return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue