mirror of
https://github.com/penpot/penpot.git
synced 2025-03-14 08:41:48 -05:00
Add many fixes to matrix operations.
This commit is contained in:
parent
0e91ae1ff7
commit
30df813edf
1 changed files with 26 additions and 25 deletions
|
@ -59,12 +59,12 @@
|
||||||
tx2 (:tx om)
|
tx2 (:tx om)
|
||||||
ty2 (:ty om)]
|
ty2 (:ty om)]
|
||||||
(Matrix.
|
(Matrix.
|
||||||
(+ (* a2 a1) (* c2 b1))
|
(+ (* a2 a1) (* c2 c1))
|
||||||
(+ (* b2 a1) (* d2 b1))
|
(+ (* a2 b1) (* c2 d1))
|
||||||
(+ (* a2 c1) (* c2 d1))
|
(+ (* b2 a1) (* d2 c1))
|
||||||
(+ (* b2 c1) (* d2 d1))
|
(+ (* b2 b1) (* d2 d1))
|
||||||
(+ tx1 (* tx2 a1) (* ty2 b1))
|
(+ tx1 (* tx2 a1) (* ty2 c1))
|
||||||
(+ ty1 (* tx2 c1) (* ty2 d1)))))
|
(+ ty1 (* tx2 b1) (* ty2 d1)))))
|
||||||
([m om & others]
|
([m om & others]
|
||||||
(reduce multiply (multiply m om) others)))
|
(reduce multiply (multiply m om) others)))
|
||||||
|
|
||||||
|
@ -114,25 +114,26 @@
|
||||||
(rotate-matrix angle)
|
(rotate-matrix angle)
|
||||||
(translate-matrix (gpt/negate center)))))
|
(translate-matrix (gpt/negate center)))))
|
||||||
|
|
||||||
;; ([m angle]
|
(defn rotate*
|
||||||
;; (let [center (gpt/point 0 0)]
|
([m angle]
|
||||||
;; (rotate m angle center)))
|
(let [center (gpt/point 0 0)]
|
||||||
;; ([m angle center]
|
(rotate m angle center)))
|
||||||
;; (let [angle (mth/radians angle)
|
([m angle center]
|
||||||
;; x (:x center)
|
(let [angle (mth/radians angle)
|
||||||
;; y (:y center)
|
x (:x center)
|
||||||
;; cos (mth/cos angle)
|
y (:y center)
|
||||||
;; sin (mth/sin angle)
|
cos (mth/cos angle)
|
||||||
;; nsin (- sin)
|
sin (mth/sin angle)
|
||||||
;; tx (- x (+ (* x cos)) (* y sin))
|
nsin (- sin)
|
||||||
;; ty (- y (- (* x sin)) (* y cos))
|
tx (- x (+ (* x cos)) (* y sin))
|
||||||
;; a (+ (* cos (:a m)) (* sin (:b m)))
|
ty (- y (- (* x sin)) (* y cos))
|
||||||
;; b (+ (* nsin (:a m)) (* cos (:b m)))
|
a (+ (* cos (:a m)) (* sin (:c m)))
|
||||||
;; c (+ (* cos (:c m)) (* sin (:d m)))
|
b (+ (* cos (:b m)) (* sin (:d m)))
|
||||||
;; d (+ (* nsin (:c m)) (* cos (:d m)))
|
c (+ (* nsin (:a m)) (* cos (:c m)))
|
||||||
;; tx' (+ (:tx m) (* tx (:a m)) (* ty (:b m)))
|
d (+ (* nsin (:b m)) (* cos (:d m)))
|
||||||
;; ty' (+ (:ty m) (* tx (:c m)) (* ty (:d m)))]
|
tx' (+ (:tx m) (* tx (:a m)) (* ty (:c m)))
|
||||||
;; (Matrix. a b c d tx' ty'))))
|
ty' (+ (:ty m) (* tx (:b m)) (* ty (:d m)))]
|
||||||
|
(Matrix. a b c d tx' ty'))))
|
||||||
|
|
||||||
(defn scale
|
(defn scale
|
||||||
"Apply scale transformation to the matrix."
|
"Apply scale transformation to the matrix."
|
||||||
|
|
Loading…
Add table
Reference in a new issue