mirror of
https://github.com/penpot/penpot.git
synced 2026-05-10 18:48:23 +00:00
Add distance function to math ns.
This commit is contained in:
parent
c3ddf2ad32
commit
36f1690120
@ -67,3 +67,11 @@
|
||||
"Converts radians to degrees."
|
||||
[^number radiants]
|
||||
(math/toDegrees radiants))
|
||||
|
||||
(defn distance
|
||||
"Calculate the distance between two points."
|
||||
[[x1 y1] [x2 y2]]
|
||||
(let [dx (- x1 x2)
|
||||
dy (- y1 y2)]
|
||||
(-> (sqrt (+ (pow dx 2) (pow dy 2)))
|
||||
(precision 2))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user