From 711043c7ca9bd675133e9bb1c1a3ec05c83cbeba Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 10 May 2008 20:20:11 +0000 Subject: update to latest 2geom. this adds gsl dependency, doesn't seem to make inskape executable bigger (bzr r5649) --- src/2geom/transforms.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/2geom/transforms.cpp') diff --git a/src/2geom/transforms.cpp b/src/2geom/transforms.cpp index bdb6bcad3..0a27c31f6 100644 --- a/src/2geom/transforms.cpp +++ b/src/2geom/transforms.cpp @@ -45,6 +45,57 @@ Matrix operator*(Matrix const &m, Scale const &s) { return ret; } +Translate pow(Translate const &t, int n) { + return Translate(t[0]*n, t[1]*n); +} + +Coord pow(Coord x, long n) // shamelessly lifted from WP +{ + Coord result = 1; + while ( n ) { + if ( n & 1 ) { + result = result * x; + n = n-1; + } + x = x*x; + n = n/2; + } + return result; +} +Scale pow(Scale const &s, int n) { + return Scale(pow(s[0],n), pow(s[1],n)); + +} + +Rotate pow(Rotate x, long n) +{ + Rotate result(0,1); // identity + while ( n ) { + if ( n & 1 ) { + result = result * x; + n = n-1; + } + x = x*x; + n = n/2; + } + return result; +} + +Matrix pow(Matrix x, long n) +{ + Matrix result; + result.setIdentity(); + while ( n ) { + if ( n & 1 ) { + result = result * x; + n = n-1; + } + x = x*x; + n = n/2; + } + return result; +} + } /* -- cgit v1.2.3