From: Mikko Rasa Date: Sun, 19 May 2013 18:14:28 +0000 (+0300) Subject: Add multiplication and inversion operations to AffineTransformation X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=cfffb770e4dadddadb3657599811900be34244b6;p=libs%2Fmath.git Add multiplication and inversion operations to AffineTransformation --- diff --git a/source/geometry/affinetransformation.h b/source/geometry/affinetransformation.h index 93fb91a..430619e 100644 --- a/source/geometry/affinetransformation.h +++ b/source/geometry/affinetransformation.h @@ -62,6 +62,9 @@ public: static AffineTransformation scaling(const LinAl::Vector &); static AffineTransformation shear(const LinAl::Vector &, const LinAl::Vector &); + AffineTransformation &operator*=(const AffineTransformation &); + AffineTransformation &invert(); + const LinAl::SquareMatrix &get_matrix() const { return matrix; } operator const LinAl::SquareMatrix &() const { return matrix; } @@ -137,6 +140,34 @@ AffineTransformation AffineTransformationOps::rotation(const Angle +inline AffineTransformation &AffineTransformation::operator*=(const AffineTransformation &other) +{ + matrix *= other.get_matrix(); + return *this; +} + +template +inline AffineTransformation operator*(const AffineTransformation &at1, const AffineTransformation &at2) +{ + AffineTransformation r = at1; + return r *= at2; +} + +template +inline AffineTransformation &AffineTransformation::invert() +{ + matrix.invert(); + return *this; +} + +template +inline AffineTransformation invert(const AffineTransformation &at) +{ + AffineTransformation r = at; + return r.invert(); +} + template inline LinAl::Vector augment_vector(const LinAl::Vector &v, T s)