mirror of
https://github.com/penpot/penpot.git
synced 2025-07-04 12:17:18 +02: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."
|
"Converts radians to degrees."
|
||||||
[^number radiants]
|
[^number radiants]
|
||||||
(math/toDegrees 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
Add a link
Reference in a new issue