From: buliabyak Date: Fri, 30 Jun 2006 03:54:17 +0000 (+0000) Subject: add methods to identify scales and rotations X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=75c97380562ad134756e47ac5895b637d7a495c7;p=inkscape.git add methods to identify scales and rotations --- diff --git a/src/libnr/nr-matrix.cpp b/src/libnr/nr-matrix.cpp index 24fa2e206..12a2f2fcb 100644 --- a/src/libnr/nr-matrix.cpp +++ b/src/libnr/nr-matrix.cpp @@ -522,6 +522,26 @@ bool Matrix::is_translation(Coord const eps) const { } +/** + * + */ +bool Matrix::is_scale(Coord const eps) const { + return ( (fabs(_c[0] - 1.0) > eps || fabs(_c[3] - 1.0) > eps) && + fabs(_c[1]) < eps && + fabs(_c[2]) < eps ); +} + + +/** + * + */ +bool Matrix::is_rotation(Coord const eps) const { + return ( fabs(_c[1]) > eps && + fabs(_c[2]) > eps && + fabs(_c[1] + _c[2]) < 2 * eps); +} + + diff --git a/src/libnr/nr-matrix.h b/src/libnr/nr-matrix.h index 47196137e..767c2105b 100644 --- a/src/libnr/nr-matrix.h +++ b/src/libnr/nr-matrix.h @@ -248,6 +248,16 @@ class Matrix { */ bool is_translation(Coord const eps = 1e-6) const; + /** + * + */ + bool is_scale(Coord const eps = 1e-6) const; + + /** + * + */ + bool is_rotation(Coord const eps = 1e-6) const; + /** *