From e6e4cc0402b01047845c5a5756ada820fa7b0af3 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Thu, 27 Sep 2018 23:16:17 -0700 Subject: [PATCH] taking into account coordinate system direction for surface inverting --- web/app/math/bbox.js | 4 ++++ web/app/math/l3space.js | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/web/app/math/bbox.js b/web/app/math/bbox.js index c3979066..6dba8be7 100644 --- a/web/app/math/bbox.js +++ b/web/app/math/bbox.js @@ -25,6 +25,10 @@ export default class BBox { this.checkBounds(p.x, p.y, p.z); } + checkData([x, y, z]) { + this.checkBounds(x, y, z); + } + center() { return new Vector(this.minX + (this.maxX - this.minX) / 2, this.minY + (this.maxY - this.minY) / 2, diff --git a/web/app/math/l3space.js b/web/app/math/l3space.js index 859fa5ea..037684f1 100644 --- a/web/app/math/l3space.js +++ b/web/app/math/l3space.js @@ -190,6 +190,21 @@ Matrix3.prototype.__apply = function(vector, out) { return out; }; +Matrix3.prototype.apply3 = function(data) { + return this.__apply3(data, []) +}; + +Matrix3.prototype._apply3 = function(data) { + return this.__apply3(data, data); +}; + +Matrix3.prototype.__apply3 = function([x, y, z], out) { + out[0] = this.mxx * x + this.mxy * y + this.mxz * z + this.tx; + out[1] = this.myx * x + this.myy * y + this.myz * z + this.ty; + out[2] = this.mzx * x + this.mzy * y + this.mzz * z + this.tz; + return out; +}; + Matrix3.rotateMatrix = function(angle, axis, pivot) { var sin = Math.sin(angle); var cos = Math.cos(angle);