fieldkit
Version:
Basic building blocks for computational design projects. Written in CoffeeScript for browser and server environments.
56 lines (39 loc) • 1.17 kB
JavaScript
// Generated by CoffeeScript 1.6.3
(function() {
var Box, Vec3;
Vec3 = require("./vector").Vec3;
Box = (function() {
Box.prototype.x1 = 0;
Box.prototype.y1 = 0;
Box.prototype.z1 = 0;
Box.prototype.x2 = 0;
Box.prototype.y2 = 0;
Box.prototype.z2 = 0;
function Box(x1, y1, z1, x2, y2, z2) {
this.x1 = x1 != null ? x1 : 0;
this.y1 = y1 != null ? y1 : 0;
this.z1 = z1 != null ? z1 : 0;
this.x2 = x2 != null ? x2 : 0;
this.y2 = y2 != null ? y2 : 0;
this.z2 = z2 != null ? z2 : 0;
}
Box.prototype.center = function() {
var x, y, z;
x = Math.min(this.x1, this.x2) + this.width() * 0.5;
y = Math.min(this.y1, this.y2) + this.height() * 0.5;
z = Math.min(this.z1, this.z2) + this.depth() * 0.5;
return new Vec3(x, y, z);
};
Box.prototype.width = function() {
return Math.abs(this.x1 - this.x2);
};
Box.prototype.height = function() {
return Math.abs(this.y1 - this.y2);
};
Box.prototype.depth = function() {
return Math.abs(this.z1 - this.z2);
};
return Box;
})();
module.exports.Box = Box;
}).call(this);