0
Fork 0
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:
Andrey Antukh 2016-01-30 20:18:51 +02:00
parent c3ddf2ad32
commit 36f1690120

View file

@ -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))))