diff options
author | jaseg <git@jaseg.de> | 2021-06-04 00:34:39 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2021-06-04 00:34:39 +0200 |
commit | f1bf25b51f51a3a399414a9b56e006c7d66b1022 (patch) | |
tree | 526068fef131a7b8fbfcb5b9d20f5de22c0eb358 /svg-flatten/include | |
parent | 564ab243cc3fa7c0239d71a6dacb4a6c7765e9f5 (diff) | |
download | gerbolyze-f1bf25b51f51a3a399414a9b56e006c7d66b1022.tar.gz gerbolyze-f1bf25b51f51a3a399414a9b56e006c7d66b1022.tar.bz2 gerbolyze-f1bf25b51f51a3a399414a9b56e006c7d66b1022.zip |
Fix transform math
Diffstat (limited to 'svg-flatten/include')
-rw-r--r-- | svg-flatten/include/geom2d.hpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/svg-flatten/include/geom2d.hpp b/svg-flatten/include/geom2d.hpp index b4cccf2..82dbfb5 100644 --- a/svg-flatten/include/geom2d.hpp +++ b/svg-flatten/include/geom2d.hpp @@ -21,6 +21,7 @@ #include <array> #include <string> #include <sstream> +#include <iomanip> #include <cmath> #include <algorithm> @@ -67,6 +68,7 @@ namespace gerbolyze { return; xx=a, yx=b, xy=c, yy=d, x0=e, y0=f; + cerr << "xform loaded " << dbg_str() << endl; } xform2d &translate(double x, double y) { @@ -82,14 +84,14 @@ namespace gerbolyze { } xform2d &transform(const xform2d &other) { - double n_xx = xx * other.xx + yx * other.xy; - double n_yx = xx * other.yx + yx * other.yy; + double n_xx = other.xx * xx + other.yx * xy; + double n_yx = other.xx * yx + other.yx * yy; - double n_xy = xy * other.xx + yy * other.xy; - double n_yy = xy * other.yx + yy * other.yy; + double n_xy = other.xy * xx + other.yy * xy; + double n_yy = other.xy * yx + other.yy * yy; - double n_x0 = x0 * other.xx + y0 * other.xy + other.x0; - double n_y0 = x0 * other.yx + y0 * other.yy + other.y0; + double n_x0 = other.x0 * xx + other.y0 * xy + x0; + double n_y0 = other.x0 * yx + other.y0 * yy + y0; xx = n_xx; yx = n_yx; @@ -152,6 +154,15 @@ namespace gerbolyze { } } + string dbg_str() { + ostringstream os; + os << "xform2d< " << setw(5); + os << xx << ", " << xy << ", " << x0 << " / "; + os << yy << ", " << yx << ", " << y0; + os << " >"; + return os.str(); + } + private: double xx, yx, xy, yy, |