{"dependencies":[{"name":"C:\\Users\\alexbol\\WebstormProjects\\flatten-js\\package.json","includedInParent":true,"mtime":1520238055570}],"generated":{"js":"/**\r\n * Created by Alex Bol on 2/19/2017.\r\n */\n\n\"use strict\";\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nmodule.exports = function (Flatten) {\n    /**\r\n     * Class representing a vector\r\n     * @type {Vector}\r\n     */\n    Flatten.Vector = function () {\n        /**\r\n         * Vector may be constructed by two points, or by two float numbers\r\n         * @param {Point} ps - start point\r\n         * @param {Point} pe - end point\r\n         */\n        function Vector() {\n            _classCallCheck(this, Vector);\n\n            /**\r\n             * x-coordinate of a vector (float number)\r\n             * @type {number}\r\n             */\n            this.x = 0;\n            /**\r\n             * y-coordinate of a vector (float number)\r\n             * @type {number}\r\n             */\n            this.y = 0;\n\n            /* return zero vector */\n            if (arguments.length == 0) {\n                return;\n            }\n\n            if (arguments.length == 2) {\n                var a1 = arguments.length <= 0 ? undefined : arguments[0];\n                var a2 = arguments.length <= 1 ? undefined : arguments[1];\n\n                if (typeof a1 == \"number\" && typeof a2 == \"number\") {\n                    this.x = a1;\n                    this.y = a2;\n                    return;\n                }\n\n                if (a1 instanceof Flatten.Point && a2 instanceof Flatten.Point) {\n                    this.x = a2.x - a1.x;\n                    this.y = a2.y - a1.y;\n                    return;\n                }\n            }\n\n            throw Flatten.Errors.ILLEGAL_PARAMETERS;\n        }\n\n        /**\r\n         * Method clone returns new instance of Vector\r\n         * @returns {Vector}\r\n         */\n\n\n        _createClass(Vector, [{\n            key: \"clone\",\n            value: function clone() {\n                return new Vector(this.x, this.y);\n            }\n\n            /**\r\n             * Slope of the vector in radians from 0 to 2PI\r\n             * @returns {number}\r\n             */\n\n        }, {\n            key: \"equalTo\",\n\n\n            /**\r\n             * Returns true if vectors are equal up to DP_TOL tolerance\r\n             * @param {Vector} v\r\n             * @returns {boolean}\r\n             */\n            value: function equalTo(v) {\n                return Flatten.Utils.EQ(this.x, v.x) && Flatten.Utils.EQ(this.y, v.y);\n            }\n\n            /**\r\n             * Returns new vector multiplied by scalar\r\n             * @param {number} scalar\r\n             * @returns {Vector}\r\n             */\n\n        }, {\n            key: \"multiply\",\n            value: function multiply(scalar) {\n                return new Vector(scalar * this.x, scalar * this.y);\n            }\n\n            /**\r\n             * Returns scalar product between two vectors <br/>\r\n             * <code>dot_product = (this * v)</code>\r\n             * @param {Vector} v Other vector\r\n             * @returns {number}\r\n             */\n\n        }, {\n            key: \"dot\",\n            value: function dot(v) {\n                return this.x * v.x + this.y * v.y;\n            }\n\n            /**\r\n             * Returns vector product (magnitude) between two vectors <br/>\r\n             * <code>cross_product = (this x v)</code>\r\n             * @param {Vector} v Other vector\r\n             * @returns {number}\r\n             */\n\n        }, {\n            key: \"cross\",\n            value: function cross(v) {\n                return this.x * v.y - this.y * v.x;\n            }\n\n            /**\r\n             * Returns unit vector.<br/>\r\n             * Throw error if given vector has zero length\r\n             * @returns {Vector}\r\n             */\n\n        }, {\n            key: \"normalize\",\n            value: function normalize() {\n                if (!Flatten.Utils.EQ_0(this.length)) {\n                    return new Vector(this.x / this.length, this.y / this.length);\n                }\n                throw Flatten.Errors.ZERO_DIVISION;\n            }\n\n            /**\r\n             * Returns new vector rotated by given angle, positive angle defines rotation in counter clockwise direction\r\n             * @param {number} angle - Angle in radians\r\n             * @returns {Vector}\r\n             */\n\n        }, {\n            key: \"rotate\",\n            value: function rotate(angle) {\n                var point = new Flatten.Point(this.x, this.y);\n                var rpoint = point.rotate(angle);\n                return new Flatten.Vector(rpoint.x, rpoint.y);\n            }\n\n            /**\r\n             * Returns vector rotated 90 degrees counter clockwise\r\n             * @returns {Vector}\r\n             */\n\n        }, {\n            key: \"rotate90CCW\",\n            value: function rotate90CCW() {\n                return new Flatten.Vector(-this.y, this.x);\n            }\n        }, {\n            key: \"rotate90CW\",\n\n\n            /**\r\n             * Returns vector rotated 90 degrees clockwise\r\n             * @returns {Vector}\r\n             */\n            value: function rotate90CW() {\n                return new Flatten.Vector(this.y, -this.x);\n            }\n        }, {\n            key: \"invert\",\n\n\n            /**\r\n             * Return inverted vector\r\n             * @returns {Vector}\r\n             */\n            value: function invert() {\n                return new Flatten.Vector(-this.x, -this.y);\n            }\n        }, {\n            key: \"slope\",\n            get: function get() {\n                var angle = Math.atan2(this.y, this.x);\n                if (angle < 0) angle = 2 * Math.PI + angle;\n                return angle;\n            }\n\n            /**\r\n             * Length of vector\r\n             * @returns {number}\r\n             */\n\n        }, {\n            key: \"length\",\n            get: function get() {\n                return Math.sqrt(this.dot(this));\n            }\n        }]);\n\n        return Vector;\n    }();\n\n    /**\r\n     * Function to create vector equivalent to \"new\" constructor\r\n     * @param args\r\n     */\n    Flatten.vector = function () {\n        for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n            args[_key] = arguments[_key];\n        }\n\n        return new (Function.prototype.bind.apply(Flatten.Vector, [null].concat(args)))();\n    };\n};"},"hash":"a13a206114c82e6313e8f47e799f9dc9","cacheData":{"env":{}}}