/*! cornerstone-math - 0.1.10 - 2022-06-09 | (c) 2017 Chris Hafey | https://github.com/cornerstonejs/cornerstoneMath */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cornerstone-math",[],e):"object"==typeof exports?exports["cornerstone-math"]=e():t.cornerstoneMath=e()}(window,function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=4)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var n=0;nt.x&&(this.x=t.x),this.y>t.y&&(this.y=t.y),this.z>t.z&&(this.z=t.z),this}},{key:"max",value:function(t){return this.xe.x&&(this.x=e.x),this.ye.y&&(this.y=e.y),this.ze.z&&(this.z=e.z),this}},{key:"floor",value:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}},{key:"ceil",value:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}},{key:"round",value:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}},{key:"roundToZero",value:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}},{key:"negate",value:function(){return this.multiplyScalar(-1)}},{key:"dot",value:function(t){return this.x*t.x+this.y*t.y+this.z*t.z}},{key:"lengthSq",value:function(){return this.x*this.x+this.y*this.y+this.z*this.z}},{key:"length",value:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}},{key:"lengthManhattan",value:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}},{key:"normalize",value:function(){return this.divideScalar(this.length())}},{key:"setLength",value:function(t){var e=this.length();return 0!==e&&t!==e&&this.multiplyScalar(t/e),this}},{key:"lerp",value:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}},{key:"cross",value:function(t,e){if(void 0!==e)return console.warn("DEPRECATED: Vector3's .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e);var n=this.x,i=this.y,r=this.z;return this.x=i*t.z-r*t.y,this.y=r*t.x-n*t.z,this.z=n*t.y-i*t.x,this}},{key:"crossVectors",value:function(t,e){var n=t.x,i=t.y,r=t.z,o=e.x,s=e.y,a=e.z;return this.x=i*a-r*s,this.y=r*o-n*a,this.z=n*s-i*o,this}},{key:"angleTo",value:function(t){var e=this.dot(t)/(this.length()*t.length());return Math.acos((0,o.clamp)(e,-1,1))}},{key:"distanceTo",value:function(t){return Math.sqrt(this.distanceToSquared(t))}},{key:"distanceToSquared",value:function(t){var e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}},{key:"setFromMatrixPosition",value:function(t){return this.x=t.elements[12],this.y=t.elements[13],this.z=t.elements[14],this}},{key:"setFromMatrixScale",value:function(t){var e=this.set(t.elements[0],t.elements[1],t.elements[2]).length(),n=this.set(t.elements[4],t.elements[5],t.elements[6]).length(),i=this.set(t.elements[8],t.elements[9],t.elements[10]).length();return this.x=e,this.y=n,this.z=i,this}},{key:"setFromMatrixColumn",value:function(t,e){var n=4*t,i=e.elements;return this.x=i[n],this.y=i[n+1],this.z=i[n+2],this}},{key:"equals",value:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}},{key:"fromArray",value:function(t){return this.x=t[0],this.y=t[1],this.z=t[2],this}},{key:"toArray",value:function(){return[this.x,this.y,this.z]}},{key:"clone",value:function(){return new t(this.x,this.y,this.z)}}]),t}();s.prototype.projectOnVector=function(){var t=void 0,e=void 0;return function(n){return void 0===t&&(t=new s),t.copy(n).normalize(),e=this.dot(t),this.copy(t).multiplyScalar(e)}}(),s.prototype.projectOnPlane=function(){var t=void 0;return function(e){return void 0===t&&(t=new s),t.copy(this).projectOnVector(e),this.sub(t)}}(),s.prototype.reflect=function(){var t=void 0;return function(e){return void 0===t&&(t=new s),this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),s.prototype.clampScalar=function(){var t=void 0,e=void 0;return function(n,i){return void 0===t&&(t=new s,e=new s),t.set(n,n,n),e.set(i,i,i),this.clamp(t,e)}}(),s.prototype.applyAxisAngle=function(){var t=void 0;return function(e,n){return void 0===t&&(t=new r.default),this.applyQuaternion(t.setFromAxisAngle(e.normalize(),n)),this}}(),e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=1e-4;e.clamp=function(t,e,n){return tn?n:t},e.degToRad=function(t){return t*(Math.PI/180)},e.approximatelyEquals=function(t,e,n){var r=n||i;return Math.abs(t-e)<=r*Math.max(1,Math.abs(t),Math.abs(e))},e.radToDeg=function(t){return t*(180/Math.PI)},e.sign=function(t){return"number"==typeof t?t?t<0?-1:1:t==t?0:NaN:NaN}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var n=0;n0?(y=.5/Math.sqrt(c+1),this.w=.25/y,this.x=(h-a)*y,this.y=(r-u)*y,this.z=(o-i)*y):n>s&&n>l?(y=2*Math.sqrt(1+n-s-l),this.w=(h-a)/y,this.x=.25*y,this.y=(i+o)/y,this.z=(r+u)/y):s>l?(y=2*Math.sqrt(1+s-n-l),this.w=(r-u)/y,this.x=(i+o)/y,this.y=.25*y,this.z=(a+h)/y):(y=2*Math.sqrt(1+l-n-s),this.w=(o-i)/y,this.x=(r+u)/y,this.y=(a+h)/y,this.z=.25*y),this}}]),t}();e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1);function r(t){return t*t}function o(t,e){return r(t.x-e.x)+r(t.y-e.y)}var s={distanceToPoint:function(t,e){return Math.sqrt(function(t,e){var n=o(t.start,t.end);if(0===n)return o(e,t.start);var i=((e.x-t.start.x)*(t.end.x-t.start.x)+(e.y-t.start.y)*(t.end.y-t.start.y))/n;return o(e,i<0?t.start:i>1?t.end:{x:t.start.x+i*(t.end.x-t.start.x),y:t.start.y+i*(t.end.y-t.start.y)})}(t,e))},intersectLine:function(t,e){var n,r,o,s,a,u,h,l,c,y,f,d={},v=t.start.x,p=t.start.y,x=t.end.x,m=t.end.y,g=e.start.x,b=e.start.y,z=e.end.x,k=e.end.y,M=void 0;if(y=(n=m-p)*z+(o=v-x)*k+(a=x*p-v*m),(0===(c=n*g+o*b+a)||0===y||(0,i.sign)(c)!==(0,i.sign)(y))&&(l=(r=k-b)*x+(s=g-z)*m+(u=z*b-g*k),0===(h=r*v+s*p+u)||0===l||(0,i.sign)(h)!==(0,i.sign)(l))){f=n*s-r*o,M=o*u-s*a;var w=parseFloat(M/f);M=r*a-n*u;var P=parseFloat(M/f);return d.x=w,d.y=P,d}}};e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Vector3=e.rect=e.quaternion=e.point=e.Plane=e.Matrix4=e.sign=e.radToDeg=e.degToRad=e.clamp=e.lineSegment=e.Line3=void 0;var i=y(n(5)),r=y(n(3)),o=n(1),s=y(n(6)),a=y(n(7)),u=y(n(8)),h=y(n(2)),l=y(n(9)),c=y(n(0));function y(t){return t&&t.__esModule?t:{default:t}}var f={Line3:i.default,lineSegment:r.default,clamp:o.clamp,degToRad:o.degToRad,radToDeg:o.radToDeg,sign:o.sign,Matrix4:s.default,Plane:a.default,point:u.default,quaternion:h.default,rect:l.default,Vector3:c.default};e.Line3=i.default,e.lineSegment=r.default,e.clamp=o.clamp,e.degToRad=o.degToRad,e.radToDeg=o.radToDeg,e.sign=o.sign,e.Matrix4=s.default,e.Plane=a.default,e.point=u.default,e.quaternion=h.default,e.rect=l.default,e.Vector3=c.default,e.default=f},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var n=0;n1||isNaN(u))){var h=this.start.clone().add(e.clone().multiplyScalar(u));return h.clone().sub(t.start).lengthSq()+h.clone().sub(t.end).lengthSq()<=t.distanceSq()?h:void 0}}}}]),t}();e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var n=0;n0||n<0&&e>0}},{key:"intersectPlane",value:function(t){var e=this.normal.clone().cross(t.normal),n={origin:new r.default,direction:e};if(this.normal.clone().cross(t.normal).length<1e-10)return n.direction=new r.default,n;var i=this.constant,o=t.constant,s=this.normal.clone().dot(t.normal),a=-(i-o*s)/(1-s*s),u=-(o-i*s)/(1-s*s);return n.origin=this.normal.clone().multiplyScalar(a).add(t.normal.clone().multiplyScalar(u)),n}},{key:"coplanarPoint",value:function(t){return(t||new r.default).copy(this.normal).multiplyScalar(-this.constant)}},{key:"translate",value:function(t){return this.constant=this.constant-t.dot(this.normal),this}},{key:"equals",value:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}},{key:"clone",value:function(){return(new t).copy(this)}}]),t}();o.prototype.setFromCoplanarPoints=function(){var t=new r.default,e=new r.default;return function(n,i,r){var o=t.subVectors(r,i).cross(e.subVectors(n,i)).normalize();return this.setFromNormalAndCoplanarPoint(o,n),this}}(),o.prototype.intersectLine=function(){var t=new r.default;return function(e,n){var i=n||new r.default,o=e.delta(t),s=this.normal.dot(o);if(0===s)return 0===this.distanceToPoint(e.start)?i.copy(e.start):void 0;var a=-(e.start.dot(this.normal)+this.constant)/s;return a<0||a>1?void 0:i.copy(o).multiplyScalar(a).add(e.start)}}(),e.default=o},function(t,e,n){"use strict";function i(t,e){return{x:t.x-e.x,y:t.y-e.y}}function r(t,e){return Math.sqrt(o(t,e))}function o(t,e){var n=i(t,e);return n.x*n.x+n.y*n.y}Object.defineProperty(e,"__esModule",{value:!0});var s={subtract:i,copy:function(t){return{x:t.x,y:t.y}},pageToPoint:function(t){return{x:t.pageX,y:t.pageY}},distance:r,distanceSquared:o,insideRect:function(t,e){return!(t.xe.left+e.width||t.ye.top+e.height)},findClosestPoint:function(t,e){var n=[],i=void 0;return t.forEach(function(t,o){var s=r(t,e);n.push(s),i=0===o?s:Math.min(s,i)}),t[n.indexOf(i)]}};e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(t){return t&&t.__esModule?t:{default:t}}(n(3));function r(t){return{topLeft:{x:t.left,y:t.top},bottomRight:{x:t.left+t.width,y:t.top+t.height}}}var o={distanceToPoint:function(t,e){var n=655535;return function(t){return[{start:{x:t.left,y:t.top},end:{x:t.left+t.width,y:t.top}},{start:{x:t.left+t.width,y:t.top},end:{x:t.left+t.width,y:t.top+t.height}},{start:{x:t.left+t.width,y:t.top+t.height},end:{x:t.left,y:t.top+t.height}},{start:{x:t.left,y:t.top+t.height},end:{x:t.left,y:t.top}}]}(t).forEach(function(t){var r=i.default.distanceToPoint(t,e);r=0?e.width>=0?!(o.bottomRight.x<=s.topLeft.x||s.bottomRight.x<=o.topLeft.x):!(o.bottomRight.x<=s.bottomRight.x||s.topLeft.x<=o.topLeft.x):e.width>=0?!(o.topLeft.x<=s.topLeft.x||s.bottomRight.x<=o.bottomRight.x):!(o.topLeft.x<=s.bottomRight.x||s.topLeft.x<=o.bottomRight.x),i=t.height>=0?e.height>=0?!(o.bottomRight.y<=s.topLeft.y||s.bottomRight.y<=o.topLeft.y):!(o.bottomRight.y<=s.bottomRight.y||s.topLeft.y<=o.topLeft.y):e.height>=0?!(o.topLeft.y<=s.topLeft.y||s.bottomRight.y<=o.bottomRight.y):!(o.topLeft.y<=s.bottomRight.y||s.top<=o.bottomRight.y),n&&i}(t,e)){var i=r(t),o=r(e);return t.width>=0?e.width>=0?(n.topLeft.x=Math.max(i.topLeft.x,o.topLeft.x),n.bottomRight.x=Math.min(i.bottomRight.x,o.bottomRight.x)):(n.topLeft.x=Math.max(i.topLeft.x,o.bottomRight.x),n.bottomRight.x=Math.min(i.bottomRight.x,o.topLeft.x)):e.width>=0?(n.topLeft.x=Math.min(i.topLeft.x,o.bottomRight.x),n.bottomRight.x=Math.max(i.bottomRight.x,o.topLeft.x)):(n.topLeft.x=Math.min(i.topLeft.x,o.topLeft.x),n.bottomRight.x=Math.max(i.bottomRight.x,o.bottomRight.x)),t.height>=0?e.height>=0?(n.topLeft.y=Math.max(i.topLeft.y,o.topLeft.y),n.bottomRight.y=Math.min(i.bottomRight.y,o.bottomRight.y)):(n.topLeft.y=Math.max(i.topLeft.y,o.bottomRight.y),n.bottomRight.y=Math.min(i.bottomRight.y,o.topLeft.y)):e.height>=0?(n.topLeft.y=Math.min(i.topLeft.y,o.bottomRight.y),n.bottomRight.y=Math.max(i.bottomRight.y,o.topLeft.y)):(n.topLeft.y=Math.min(i.topLeft.y,o.topLeft.y),n.bottomRight.y=Math.max(i.bottomRight.y,o.bottomRight.y)),n}}};e.default=o}])}); //# sourceMappingURL=cornerstoneMath.min.js.map