File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 16
16
[x1 y1 x2 y2])))
17
17
18
18
(defn union
19
+ " Calculates the bounds that contain an arbitrary set of bounds."
19
20
[& bounds]
20
21
(concat (apply map min (map #(take 2 %) bounds))
21
22
(apply map max (map #(drop 2 %) bounds))))
26
27
(mat/sub [x2 y2] [x1 y1]))
27
28
28
29
(defn center
30
+ " Calculates the center of bounds."
29
31
[bounds]
30
- (let [[x1 y1 _x2 _y2] bounds]
31
- ( mat/add [x1 y1] (mat/div (->dimensions bounds) 2 ) )))
32
+ (mat/add ( take 2 bounds)
33
+ (mat/div (->dimensions bounds) 2 )))
32
34
33
35
(defn intersect?
36
+ " Tests whether the provided set of bounds intersect."
34
37
[a-bounds b-bounds]
35
38
(when (and a-bounds b-bounds)
36
39
(let [[a-left a-top a-right a-bottom] a-bounds
41
44
(< b-bottom a-top))))))
42
45
43
46
(defn contained?
47
+ " Tests whether `bounds-a` fully contain `bounds-b`."
44
48
[a-bounds b-bounds]
45
49
(when (and a-bounds b-bounds)
46
50
(let [[a-left a-top a-right a-bottom] a-bounds
51
55
(< a-bottom b-bottom)))))
52
56
53
57
(defn contain-point?
58
+ " Tests whether the provided bounds contain a point."
54
59
[[left top right bottom] [x y]]
55
60
(and (<= left x)
56
61
(<= top y)
Original file line number Diff line number Diff line change 22
22
(mod angle (* 2 Math/PI)))
23
23
24
24
(defn angle
25
+ " Calculates the angle between two points."
25
26
[x1 y1 x2 y2]
26
27
(-> (Math/atan2 (- y2 y1) (- x2 x1))
27
28
normalize-angle
You can’t perform that action at this time.
0 commit comments