mirror of
https://github.com/penpot/penpot.git
synced 2025-04-14 07:51:35 -05:00
🐛 Fixed problem with divide by zero
This commit is contained in:
parent
3543acbac7
commit
912be76400
3 changed files with 16 additions and 26 deletions
|
@ -148,17 +148,18 @@
|
|||
(assert (point? p))
|
||||
(assert (point? other))
|
||||
|
||||
(if (or (= 0 (length p))
|
||||
(= 0 (length other)))
|
||||
0
|
||||
(let [a (/ (+ (* x ox)
|
||||
(* y oy))
|
||||
(* (length p)
|
||||
(length other)))
|
||||
a (mth/acos (if (< a -1) -1 (if (> a 1) 1 a)))
|
||||
d (-> (mth/degrees a)
|
||||
(mth/precision 6))]
|
||||
(if (mth/nan? d) 0 d))))
|
||||
(let [length-p (length p)
|
||||
length-other (length other)]
|
||||
(if (or (mth/almost-zero? length-p)
|
||||
(mth/almost-zero? length-other))
|
||||
0
|
||||
(let [a (/ (+ (* x ox)
|
||||
(* y oy))
|
||||
(* length-p length-other))
|
||||
a (mth/acos (if (< a -1) -1 (if (> a 1) 1 a)))
|
||||
d (-> (mth/degrees a)
|
||||
(mth/precision 6))]
|
||||
(if (mth/nan? d) 0 d)))))
|
||||
|
||||
|
||||
(defn update-angle
|
||||
|
|
|
@ -167,7 +167,7 @@
|
|||
|
||||
h1 (calculate-height points-temp)
|
||||
h2 (calculate-height (transform-points points-rec center stretch-matrix))
|
||||
h3 (/ h1 h2)
|
||||
h3 (if-not (mth/almost-zero? h2) (/ h1 h2) 1)
|
||||
h3 (if (mth/nan? h3) 1 h3)
|
||||
|
||||
stretch-matrix (gmt/multiply stretch-matrix (gmt/scale-matrix (gpt/point 1 h3)))
|
||||
|
|
|
@ -110,17 +110,6 @@
|
|||
|
||||
(update data :pages-index #(d/mapm update-page %))))
|
||||
|
||||
(defmethod migrate 4
|
||||
[data]
|
||||
(letfn [(update-object [id object]
|
||||
(cond-> object
|
||||
(= (:id object) uuid/zero)
|
||||
(assoc :points []
|
||||
:selrect {:x 0 :y 0
|
||||
:width 1 :height 1
|
||||
:x1 0 :y1 0
|
||||
:x2 1 :y2 1})))
|
||||
|
||||
(update-page [id page]
|
||||
(update page :objects #(d/mapm update-object %)))]
|
||||
(update data :pages-index #(d/mapm update-page %))))
|
||||
;; We did rollback version 4 migration.
|
||||
;; Keep this in order to remember the next version to be 5
|
||||
(defmethod migrate 4 [data] data)
|
||||
|
|
Loading…
Add table
Reference in a new issue