flatten-js
Version:
Javascript library for 2d geometry
1 lines • 2.18 kB
JSON
{"dependencies":[{"name":"C:\\Users\\alexbol\\WebstormProjects\\flatten-js\\package.json","includedInParent":true,"mtime":1520238055570}],"generated":{"js":"\"use strict\";var t=function(){function t(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,\"value\"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(n,e,r){return e&&t(n.prototype,e),r&&t(n,r),n}}();function n(t,n){if(!(t instanceof n))throw new TypeError(\"Cannot call a class as a function\")}module.exports=function(e){e.Vector=function(){function r(){if(n(this,r),this.x=0,this.y=0,0!=arguments.length){if(2==arguments.length){var t=arguments.length<=0?void 0:arguments[0],i=arguments.length<=1?void 0:arguments[1];if(\"number\"==typeof t&&\"number\"==typeof i)return this.x=t,void(this.y=i);if(t instanceof e.Point&&i instanceof e.Point)return this.x=i.x-t.x,void(this.y=i.y-t.y)}throw e.Errors.ILLEGAL_PARAMETERS}}return t(r,[{key:\"clone\",value:function(){return new r(this.x,this.y)}},{key:\"equalTo\",value:function(t){return e.Utils.EQ(this.x,t.x)&&e.Utils.EQ(this.y,t.y)}},{key:\"multiply\",value:function(t){return new r(t*this.x,t*this.y)}},{key:\"dot\",value:function(t){return this.x*t.x+this.y*t.y}},{key:\"cross\",value:function(t){return this.x*t.y-this.y*t.x}},{key:\"normalize\",value:function(){if(!e.Utils.EQ_0(this.length))return new r(this.x/this.length,this.y/this.length);throw e.Errors.ZERO_DIVISION}},{key:\"rotate\",value:function(t){var n=new e.Point(this.x,this.y).rotate(t);return new e.Vector(n.x,n.y)}},{key:\"rotate90CCW\",value:function(){return new e.Vector(-this.y,this.x)}},{key:\"rotate90CW\",value:function(){return new e.Vector(this.y,-this.x)}},{key:\"invert\",value:function(){return new e.Vector(-this.x,-this.y)}},{key:\"slope\",get:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t=2*Math.PI+t),t}},{key:\"length\",get:function(){return Math.sqrt(this.dot(this))}}]),r}(),e.vector=function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return new(Function.prototype.bind.apply(e.Vector,[null].concat(n)))}};"},"hash":"02a5d158e1ead6abc417f8f413991eb8","cacheData":{"env":{}}}