aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svg-flatten/src/test/nopencv_test.cpp29
-rw-r--r--svg-flatten/testdata/svg/xform_uniformity_threshold.svg12
2 files changed, 22 insertions, 19 deletions
diff --git a/svg-flatten/src/test/nopencv_test.cpp b/svg-flatten/src/test/nopencv_test.cpp
index 4a4634c..77ea711 100644
--- a/svg-flatten/src/test/nopencv_test.cpp
+++ b/svg-flatten/src/test/nopencv_test.cpp
@@ -336,19 +336,22 @@ MU_TEST(test_transform_decomposition) {
double ms[] = {0, -5.0, -1.0, -0.1, 0.1, 0.5, 1.0, 2.0, 5.0, 6.123, 100.0};
for (double &s_x : scales) {
for (double &s_y : scales) {
- for (int i_theta=0; i_theta<25; i_theta++) {
- double theta = i_theta * std::numbers::pi / 12.0;
- for (double &m : ms) {
- xform2d xf;
- //cerr << endl << "testing s_x=" << s_x << ", s_y=" << s_y << ", m=" << m << ", theta=" << theta << endl;
- xf.rotate(theta).skew(m).scale(s_x, s_y);
- //cerr << " -> " << xf.dbg_str() << endl;
- const auto [dec_s_x, dec_s_y, dec_m, dec_theta] = xf.decompose();
- mu_assert(fabs(s_x - dec_s_x) < 1e-9, "s_x incorrect");
- mu_assert(fabs(s_y - dec_s_y) < 1e-9, "s_y incorrect");
- mu_assert(fabs(m - dec_m) < 1e-9, "m incorrect");
- double a = dec_theta - theta + std::numbers::pi;
- mu_assert(fabs(a - floor(a/(2*std::numbers::pi)) * 2 * std::numbers::pi - std::numbers::pi) < 1e-12, "theta incorrect");
+ for (int s_y_sign=0; s_y_sign<2; s_y_sign++) {
+ double s_y_i = s_y_sign ? -s_y : s_y;
+ for (int i_theta=0; i_theta<25; i_theta++) {
+ double theta = i_theta * std::numbers::pi / 12.0;
+ for (double &m : ms) {
+ xform2d xf;
+ //cerr << endl << "testing s_x=" << s_x << ", s_y=" << s_y_i << ", m=" << m << ", theta=" << theta << endl;
+ xf.rotate(theta).skew(m).scale(s_x, s_y_i);
+ //cerr << " -> " << xf.dbg_str() << endl;
+ const auto [dec_s_x, dec_s_y, dec_m, dec_theta] = xf.decompose();
+ mu_assert(fabs(s_x - dec_s_x) < 1e-9, "s_x incorrect");
+ mu_assert(fabs(s_y_i - dec_s_y) < 1e-9, "s_y incorrect");
+ mu_assert(fabs(m - dec_m) < 1e-9, "m incorrect");
+ double a = dec_theta - theta + std::numbers::pi;
+ mu_assert(fabs(a - floor(a/(2*std::numbers::pi)) * 2 * std::numbers::pi - std::numbers::pi) < 1e-12, "theta incorrect");
+ }
}
}
}
diff --git a/svg-flatten/testdata/svg/xform_uniformity_threshold.svg b/svg-flatten/testdata/svg/xform_uniformity_threshold.svg
index 90fb3c8..d9a6c02 100644
--- a/svg-flatten/testdata/svg/xform_uniformity_threshold.svg
+++ b/svg-flatten/testdata/svg/xform_uniformity_threshold.svg
@@ -3,8 +3,8 @@
<svg
width="80mm"
- height="100mm"
- viewBox="0 0 80 100"
+ height="160mm"
+ viewBox="0 0 80 160"
version="1.1"
id="svg5"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
@@ -24,9 +24,9 @@
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="false"
- inkscape:zoom="1.5760525"
- inkscape:cx="162.74839"
- inkscape:cy="175.75557"
+ inkscape:zoom="8.6041055"
+ inkscape:cx="139.00341"
+ inkscape:cy="420.14827"
inkscape:window-width="1920"
inkscape:window-height="1011"
inkscape:window-x="0"
@@ -39,7 +39,7 @@
x="31.361818"
y="59.900364"
width="249.94496"
- height="98.717278"
+ height="98.71728"
id="rect256" />
</defs>
<g