-
Notifications
You must be signed in to change notification settings - Fork 14
/
IKRS.BoundingBox3.js~
113 lines (79 loc) · 2.61 KB
/
IKRS.BoundingBox3.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
* @author Ikaros Kappler
* @date 2014-03-30
* @version 1.0.0
**/
IKRS.BoundingBox3 = function( _xMin,
_xMax,
_yMin,
_yMax,
_zMin,
_zMax
) {
IKRS.Object.call( this );
this.xMin = _xMin;
this.xMax = _xMax;
this.yMin = _yMin;
this.yMax = _yMax;
this.zMin = _zMin;
this.zmax = _zMax;
}
IKRS.BoundingBox2.prototype = new IKRS.Object();
IKRS.BoundingBox2.prototype.constructor = IKRS.BoundingBox2;
IKRS.BoundingBox2.prototype.toString = function() {
return "IKRS.BoundingBox2={ xMin: " + this.xMin + ", xMax: " + this.xMax + ", yMin: " + this.yMin + ", yMax: " + this.yMax + ", width: " + this.getWidth() + ", height: " + this.getHeight() + " }";
}
IKRS.BoundingBox2.prototype.getXMax = function() {
return this.xMax;
}
IKRS.BoundingBox2.prototype.getXMin = function() {
return this.xMin;
}
IKRS.BoundingBox2.prototype.getYMax = function() {
return this.yMax;
}
IKRS.BoundingBox2.prototype.getYMin = function() {
return this.yMin;
}
IKRS.BoundingBox2.prototype.getWidth = function() {
return this.xMax - this.xMin;
}
IKRS.BoundingBox2.prototype.getHeight = function() {
return this.yMax - this.yMin;
}
IKRS.BoundingBox2.prototype.getLeftUpperPoint = function() {
return new THREE.Vector2( this.xMin, this.yMin );
}
IKRS.BoundingBox2.prototype.getRightUpperPoint = function() {
return new THREE.Vector2( this.xMax, this.yMin );
}
IKRS.BoundingBox2.prototype.getRightLowerPoint = function() {
return new THREE.Vector2( this.xMax, this.yMax );
}
IKRS.BoundingBox2.prototype.getLeftLowerPoint = function() {
return new THREE.Vector2( this.xMin, this.yMax );
}
IKRS.BoundingBox2.prototype._toString = function() {
return "[IKRS.BoundingBox2]={ xMin=" + this.xMin + ", xMax=" + this.xMax + ", yMin=" + this.yMin + ", yMax=" + this.yMax + ", width=" + this.getWidth() + ", height=" + this.getHeight() + " }";
}
// A static function
IKRS.BoundingBox2.computeFromPoints = function( points ) {
if( !points )
points = [];
if( points.length == 0 )
return new IKRS.BoundingBox2( 0, 0, 0, 0 );
var xMin = points[0].x;
var xMax = points[0].x;
var yMin = points[0].y;
var yMax = points[0].y;
for( var i = 1; i < points.length; i++ ) {
var point = points[ i ];
xMin = Math.min( xMin, point.x );
xMax = Math.max( xMax, point.x );
yMin = Math.min( yMin, point.y );
yMax = Math.max( yMax, point.y );
}
return new IKRS.BoundingBox2( xMin, xMax, yMin, yMax );
}
//IKRS.BoundingBox2.prototype = new IKRS.Object();
//IKRS.BoundingBox2.prototype.constructor = IKRS.BoundingBox2;