diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2008-05-10 20:20:11 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2008-05-10 20:20:11 +0000 |
| commit | 711043c7ca9bd675133e9bb1c1a3ec05c83cbeba (patch) | |
| tree | 9395fdf4cc57a8192fc0ebe506dd0f5b9db0d9d3 /src/2geom/transforms.cpp | |
| parent | Do not show/edit image URL for data URIs. (diff) | |
| download | inkscape-711043c7ca9bd675133e9bb1c1a3ec05c83cbeba.tar.gz inkscape-711043c7ca9bd675133e9bb1c1a3ec05c83cbeba.zip | |
update to latest 2geom. this adds gsl dependency, doesn't seem to make inskape executable bigger
(bzr r5649)
Diffstat (limited to 'src/2geom/transforms.cpp')
| -rw-r--r-- | src/2geom/transforms.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
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; +} + } /* |
