-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
38 lines (31 loc) · 863 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var BB = function (width, height, x, y) {
var hw = width / 2.0;
var hh = height / 2.0;
this.l = -hw + x;
this.b = -hh + y;
this.r = hw + x;
this.t = hh + y;
};
BB.prototype.intersects1 = function (b) {
var a = this;
return (a.l <= b.r && b.l <= a.r && a.b <= b.t && b.b <= a.t);
};
BB.prototype.intersects2 = function (b) {
var a = this;
return !(a.l > b.r && b.l > a.r && a.b > b.t && b.b > a.t);
};
BB.prototype.not_intersects = function (b) {
var a = this;
return (a.l > b.r && b.l > a.r && a.b > b.t && b.b > a.t);
};
var random = function(min, max) {
if (!(max)) {
max = min
min = 0
}
return min + Math.random() * (max - min)
}
var boxes = []
for (var i = 0; i < 100; i++) {
boxes.push(new BB(random(50, 200), random(50, 200), random(-1000, 1000), random(-1000, 1000)))
}