diff --git a/src/common/tvgMath.cpp b/src/common/tvgMath.cpp index e6b5d470..3ea69389 100644 --- a/src/common/tvgMath.cpp +++ b/src/common/tvgMath.cpp @@ -111,3 +111,11 @@ void operator*=(Point& pt, const Matrix& m) pt.x = tx; pt.y = ty; } + + +Point operator*(const Point& pt, const Matrix& m) +{ + auto tx = pt.x * m.e11 + pt.y * m.e12 + m.e13; + auto ty = pt.x * m.e21 + pt.y * m.e22 + m.e23; + return {tx, ty}; +} \ No newline at end of file diff --git a/src/common/tvgMath.h b/src/common/tvgMath.h index 0f877d91..3555885c 100644 --- a/src/common/tvgMath.h +++ b/src/common/tvgMath.h @@ -152,9 +152,9 @@ static inline void operator*=(Matrix& lhs, const Matrix& rhs) } -static inline void mathLog(Matrix* m) +static inline void mathLog(const Matrix& m) { - TVGLOG("MATH", "Matrix: [%f %f %f] [%f %f %f] [%f %f %f]", m->e11, m->e12, m->e13, m->e21, m->e22, m->e23, m->e31, m->e32, m->e33); + TVGLOG("COMMON", "Matrix: [%f %f %f] [%f %f %f] [%f %f %f]", m.e11, m.e12, m.e13, m.e21, m.e22, m.e23, m.e31, m.e32, m.e33); } @@ -163,6 +163,7 @@ static inline void mathLog(Matrix* m) /************************************************************************/ void operator*=(Point& pt, const Matrix& m); +Point operator*(const Point& pt, const Matrix& m); static inline bool mathZero(const Point& p) @@ -231,6 +232,11 @@ static inline Point operator/(const Point& lhs, const float rhs) } +static inline void mathLog(const Point& pt) +{ + TVGLOG("COMMON", "Point: [%f %f]", pt.x, pt.y); +} + /************************************************************************/ /* Interpolation functions */ /************************************************************************/