From 685a071e87d3646bc21e127180dd7e952fa51aa1 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 19 Jan 2023 15:47:25 +0100 Subject: [PATCH] :bug: Fix rounding error with matrices --- common/src/app/common/geom/shapes/transforms.cljc | 10 +++++++++- frontend/src/app/main/data/workspace/modifiers.cljs | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/geom/shapes/transforms.cljc b/common/src/app/common/geom/shapes/transforms.cljc index c3035df27..cbff62e3a 100644 --- a/common/src/app/common/geom/shapes/transforms.cljc +++ b/common/src/app/common/geom/shapes/transforms.cljc @@ -238,7 +238,15 @@ points-transform-mtx (gmt/translate-matrix center))) - transform-inverse (when transform (gmt/inverse transform))] + transform-inverse (when transform (gmt/inverse transform)) + + ;; There is a rounding error when the matrix returned have float point values + ;; when the matrix is unit we return a "pure" matrix so we don't accumulate + ;; rounding problems + [transform transform-inverse] + (if (gmt/unit? transform) + [(gmt/matrix) (gmt/matrix)] + [transform transform-inverse])] [sr transform transform-inverse])) diff --git a/frontend/src/app/main/data/workspace/modifiers.cljs b/frontend/src/app/main/data/workspace/modifiers.cljs index 717dfa7fe..de4782c4a 100644 --- a/frontend/src/app/main/data/workspace/modifiers.cljs +++ b/frontend/src/app/main/data/workspace/modifiers.cljs @@ -219,7 +219,7 @@ result (let [[id text-modifier] (first modifiers)] (recur (rest modifiers) - (update result id apply-text-modifier text-modifier)))))) + (d/update-when result id apply-text-modifier text-modifier)))))) #_(defn apply-path-modifiers [objects path-modifiers]