"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Vec = void 0;
var decimal_js_1 = __importDefault(require("decimal.js"));
var Vec = /** @class */ (function () {
    function Vec() {
        var _vs = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            _vs[_i] = arguments[_i];
        }
        this._data = [];
        for (var i = 0; i < _vs.length; i++) {
            this._data[i] = _vs[i];
        }
    }
    Vec.prototype.copy = function (normal) {
        for (var i = 0; i < normal.dim; i++)
            this._data[i] = new decimal_js_1.default(normal._data[i]);
    };
    Object.defineProperty(Vec.prototype, "dim", {
        get: function () {
            return this._data.length;
        },
        enumerable: false,
        configurable: true
    });
    Vec.prototype.check = function (v) {
        return this.dim === v.dim;
    };
    Vec.prototype.cross = function (v) {
        if (!this.check(v))
            return;
    };
    Object.defineProperty(Vec.prototype, "extentSq", {
        get: function () {
            var res = new decimal_js_1.default(0);
            for (var i = 0; i < this._data.length; i++)
                res = res.add(this._data[i].mul(this._data[i]));
            return res;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Vec.prototype, "extent", {
        /**
         * 长度
         */
        get: function () {
            var res = this.extentSq;
            return res.squareRoot();
        },
        enumerable: false,
        configurable: true
    });
    Vec.prototype.dot = function (v) {
        if (!this.check(v))
            console.error('dim not equal');
        var res = new decimal_js_1.default(0);
        for (var i = 0; i < this._data.length; i++) {
            var ti = this._data[i];
            var vi = v._data[i];
            res = res.add(ti.mul(vi));
        }
        return res;
    };
    return Vec;
}());
exports.Vec = Vec;
