mirror of
https://github.com/penpot/penpot.git
synced 2025-06-05 07:51:41 +02:00
🎉 New stretch method
This commit is contained in:
parent
b73958efd0
commit
8886db7453
7 changed files with 179 additions and 89 deletions
|
@ -171,3 +171,22 @@
|
|||
(fn [value]
|
||||
(map->Point value))))
|
||||
|
||||
|
||||
;; Vector functions
|
||||
(defn to-vec [p1 p2]
|
||||
(subtract p2 p1))
|
||||
|
||||
(defn dot [{x1 :x y1 :y} {x2 :x y2 :y}]
|
||||
(+ (* x1 x2) (* y1 y2)))
|
||||
|
||||
(defn unit [v]
|
||||
(let [v-length (length v)]
|
||||
(divide v (point v-length v-length))))
|
||||
|
||||
(defn project [v1 v2]
|
||||
(let [v2-unit (unit v2)
|
||||
scalar-projection (dot v1 (unit v2))]
|
||||
(multiply
|
||||
v2-unit
|
||||
(point scalar-projection scalar-projection))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue