From 538a05b3597d00b197c37e1cea574b901c16312a Mon Sep 17 00:00:00 2001 From: Aitor Date: Tue, 14 Mar 2023 13:05:52 +0100 Subject: [PATCH] :sparkles: improve rotate matrix --- common/src/app/common/geom/matrix.cljc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/common/src/app/common/geom/matrix.cljc b/common/src/app/common/geom/matrix.cljc index 2e552664cd..6e9c1d46f2 100644 --- a/common/src/app/common/geom/matrix.cljc +++ b/common/src/app/common/geom/matrix.cljc @@ -198,10 +198,17 @@ (defn rotate-matrix ([angle point] - (-> (matrix) - (multiply! (translate-matrix point)) - (multiply! (rotate-matrix angle)) - (multiply! (translate-matrix (gpt/negate point))))) + (let [cx (dm/get-prop point :x) + cy (dm/get-prop point :y) + nx (- cx) + ny (- cy) + a (mth/radians angle) + c (mth/cos a) + s (mth/sin a) + ns (- s) + tx (+ (* c nx) (* ns ny) cx) + ty (+ (* s nx) (* c ny) cy)] + (Matrix. c s ns c tx ty))) ([angle] (let [a (mth/radians angle)] (Matrix. (mth/cos a)