mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 16:21:57 -05:00
Add distance function to math ns.
This commit is contained in:
parent
c3ddf2ad32
commit
36f1690120
1 changed files with 8 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue